Add authentication and User model
* Add User model * Add SessionsController * Add password authentication on User * Request authentication for all actions except sign in * Add some helpers for ApplicationController * Update features to work with mandatory authentication
This commit is contained in:
2
app/models/session.rb
Normal file
2
app/models/session.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
class Session < ActiveRecord::Base
|
||||
end
|
11
app/models/user.rb
Normal file
11
app/models/user.rb
Normal file
@@ -0,0 +1,11 @@
|
||||
class User < ActiveRecord::Base
|
||||
validates_presence_of :email
|
||||
validates_presence_of :password
|
||||
|
||||
def self.authenticate(email, password)
|
||||
user = find_by_email(email)
|
||||
return false if user.nil?
|
||||
#FIXME use bcrypt
|
||||
return user if user.password == password
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user