refactor User and TrustLevel a bit

* rename `User#password_required` to `User#password_required!`
* emails with "i" @ something are a special case as well
* get rid of `self.` and returns where possible
* prefer "unless a" instead of "if !a"
* `unread_notifications` without manually iterating
* introduce `User#moderator?`
* introduce `TrustLevel#valid_key?`, `TrustLevel#compare`, and
  `TrustLevel#level_key`
This commit is contained in:
Gosha Arinich
2013-02-28 16:08:56 +03:00
parent 46a02ae5b1
commit d2f3c829db
6 changed files with 109 additions and 117 deletions

View File

@ -143,7 +143,7 @@ class UsersController < ApplicationController
if auth && auth[:email] == params[:email] && auth[:email_valid]
user.active = true
end
user.password_required unless auth
user.password_required! unless auth
DiscourseHub.register_nickname( user.username, user.email ) if user.valid? and SiteSetting.call_discourse_hub?