lib/blogaze/models/user.rb in blogaze-0.1.0 vs lib/blogaze/models/user.rb in blogaze-0.2.0

- old
+ new

@@ -1,36 +1,46 @@ # # Blogaze # Copyright (C) 2011-2013 Jack Polgar # # Blogaze is released under the BSD 3-clause license. -# @license http://opensource.org/licenses/BSD-3-Clause +# http://opensource.org/licenses/BSD-3-Clause # module Blogaze module Models + ## + # User model + # class User < Sequel::Model plugin :validation_helpers one_to_many :post many_to_one :group ## # Check if the users password matches # the supplied password. # + # @param [String] password + # def check_password(password) BCrypt::Password.new(self.password) == password end ## # Changes the users password. # + # @param [String] new_password + # def change_password(new_password) self.password = BCrypt::Password.create(new_password) end + ## + # Validations + # def validate super # Username validates_unique :username @@ -47,12 +57,9 @@ end def before_create self.password = BCrypt::Password.create(self.password) self.group_id = 3 - end - - def before_save end end # User end # Models end # Blogaze