Module: CowAuth::SessionAuth::SessionEndpoints

Extended by:
ActiveSupport::Concern
Defined in:
lib/cow_auth/session_auth/session_endpoints.rb

Instance Method Summary collapse

Instance Method Details

#createObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/cow_auth/session_auth/session_endpoints.rb', line 11

def create
  user = authentication_class.find_by(email: params[:email])
  if user.try(:authenticate_with_password, params[:password])
    session[:current_user] = user.sid
    redirect_to 
  else
    session[:current_user] = nil
    raise CowAuth::NotAuthenticatedError.new('Invalid user credentials.')
  end
end

#destroyObject



22
23
24
25
26
27
28
29
# File 'lib/cow_auth/session_auth/session_endpoints.rb', line 22

def destroy
  if @current_user.present?
    session[:current_user] = nil
    redirect_to sign_out_success_path
  else
    raise CowAuth::StandardError.new('Could not sign user out.')
  end
end

#newObject



8
9
# File 'lib/cow_auth/session_auth/session_endpoints.rb', line 8

def new
end