Class: HyperKittenMeow::Admin::SessionsController
- Inherits:
-
AdminController
- Object
- ActionController::Base
- AdminController
- HyperKittenMeow::Admin::SessionsController
show all
- Defined in:
- app/controllers/hyper_kitten_meow/admin/sessions_controller.rb
Instance Method Summary
collapse
#authorize, #current_user, #logged_in?
Instance Method Details
#create ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/hyper_kitten_meow/admin/sessions_controller.rb', line 9
def create
permitted = params.require(:session).permit([:email, :password])
user = User.find_by(email: permitted[:email].downcase)
if user && user.authenticate(permitted[:password])
user.set_encrypted_remember_token!
session[:user_id] = user.id
cookies.permanent.signed[:user_id] = user.id
cookies.permanent[:remember_token] = user.remember_token
redirect_to admin_posts_path
else
flash.now[:error] = t("sessions.failed_login")
render 'new'
end
end
|
#destroy ⇒ Object
26
27
28
29
30
31
|
# File 'app/controllers/hyper_kitten_meow/admin/sessions_controller.rb', line 26
def destroy
session.delete(:user_id)
cookies.delete(:user_id)
cookies.delete(:remember_token)
redirect_to root_url
end
|
#new ⇒ Object
6
7
|
# File 'app/controllers/hyper_kitten_meow/admin/sessions_controller.rb', line 6
def new
end
|