This repository was archived by the owner on Mar 9, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +45
-0
lines changed
Expand file tree Collapse file tree 4 files changed +45
-0
lines changed Original file line number Diff line number Diff line change 11class SessionsController < ApplicationController
2+
3+ def create
4+ user = login ( params [ :email ] , params [ :password ] , params [ :remember_me ] )
5+ if user
6+ redirect_back_or_to root_url , :notice => "Logged in!"
7+ else
8+ flash . now . alert = "Email or password was invalid"
9+ render :new
10+ end
11+ end
12+
13+ def destroy
14+ logout
15+ redirect_to root_url , :notice => "Logged out!"
16+ end
17+
218end
Original file line number Diff line number Diff line change 1010
1111<%= yield %>
1212
13+ <% if current_user %>
14+ Logged in as <%= current_user . email %> .
15+ <%= link_to "Log out" , logout_path %>
16+ <% else %>
17+ <%= link_to "Sign up" , signup_path %> or
18+ <%= link_to "log in" , login_path %> .
19+ <% end %>
20+
1321</ body >
1422</ html >
Original file line number Diff line number Diff line change 1+ <%= form_tag sessions_path do %>
2+ <div class ="field ">
3+ <%= label_tag :email %>
4+ <%= text_field_tag :email , params [ :email ] %>
5+ </ div >
6+ < div class ="field ">
7+ <%= label_tag :password %>
8+ <%= password_field_tag :password %>
9+ </ div >
10+ < div class ="field ">
11+ <%= check_box_tag :remember_me , 1 , params [ :remember_me ] %>
12+ <%= label_tag :remember_me %>
13+ </ div >
14+ < div class ="actions "> <%= submit_tag "Log in" %> </ div >
15+ <% end %>
Original file line number Diff line number Diff line change 77 # You can have the root of your site routed with "root"
88 root 'welcome#index'
99
10+ # authentication routes for sorcery
11+ get "logout" => "sessions#destroy" , :as => "logout"
12+ get "login" => "sessions#new" , :as => "login"
13+ get "signup" => "people#new" , :as => "signup"
14+
1015 # Example of regular route:
1116 # get 'products/:id' => 'catalog#view'
1217
1722 # resources :products
1823
1924 resources :people
25+ resources :sessions
2026
2127 # Example resource route with options:
2228 # resources :products do
You can’t perform that action at this time.
0 commit comments