Sha256: f04fe2546ca48281848665c00919d73ec38a7e0a25b95a267965ff4f56eac9fc
Contents?: true
Size: 953 Bytes
Versions: 12
Compression:
Stored size: 953 Bytes
Contents
class SessionsController < ApplicationController skip_before_action :authenticate, except: :destroy def new @<%= singular_table_name %> = <%= class_name %>.new end def create @<%= singular_table_name %> = <%= class_name %>.find_by_email(params[:email]) if @<%= singular_table_name %>.try(:authenticate, params[:password]) if params[:remember_me] == "1" cookies.permanent[:session_token] = { value: @<%= singular_table_name %>.session_token, httponly: true } else cookies[:session_token] = { value: @<%= singular_table_name %>.session_token, httponly: true } end redirect_to root_path, notice: "Signed in successfully" else redirect_to sign_in_path(email_hint: params[:email]), alert: "Invalid email or password" end end def destroy Current.<%= singular_table_name %>.regenerate_session_token redirect_to sign_in_path, notice: "Signed out successfully" end end
Version data entries
12 entries across 12 versions & 1 rubygems