forked from External/greenlight
51 lines
1.0 KiB
Ruby
51 lines
1.0 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class SessionsController < ApplicationController
|
|
# GET /users/login
|
|
def new
|
|
end
|
|
|
|
# GET /users/logout
|
|
def destroy
|
|
logout
|
|
redirect_to root_path
|
|
end
|
|
|
|
# POST /users/login
|
|
def create
|
|
user = User.find_by(email: session_params[:email])
|
|
if user.&authenticate(session_params[:password])
|
|
login(user)
|
|
end
|
|
end
|
|
|
|
# POST /launch
|
|
def launch
|
|
# This will recieve a encoded POST from a launcher that
|
|
# contains the provider, and all user information. The
|
|
# launcher is what does the authentication, so we know
|
|
# that the user is who they say they are. We just need
|
|
# to use our secret to decode it and then log them in
|
|
# to GreenLight (or sign them up).
|
|
|
|
# User.from_launch()
|
|
end
|
|
|
|
# GET/POST /auth/:provider/callback
|
|
def omniauth
|
|
user = User.from_omniauth(request.env['omniauth.auth'])
|
|
login(user)
|
|
end
|
|
|
|
# POST /auth/failure
|
|
def fail
|
|
redirect_to root_path
|
|
end
|
|
|
|
private
|
|
|
|
def session_params
|
|
params.require(:session).permit(:email, :password)
|
|
end
|
|
end
|