-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use google-sso instead of CAS for authentication (#252)
* add sso login Co-authored-by: Rayhan <[email protected]> * fix barito_superadmin not assigned correctly Co-authored-by: Beni Budiharto <[email protected]> * add deactivated_at attribute for User model Co-authored-by: Beni Budiharto <[email protected]> * remove CAS integration Co-authored-by: Beni Budiharto <[email protected]> * fix omniauth error on build Co-authored-by: Beni Budiharto <[email protected]> * add additional application.yml config example Co-authored-by: Beni Budiharto <[email protected]> Co-authored-by: Rayhan <[email protected]> Co-authored-by: Rayhan Gusty Alif <[email protected]>
- Loading branch information
1 parent
1b30443
commit a2d3cd6
Showing
20 changed files
with
208 additions
and
135 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,3 +34,6 @@ coverage | |
# Ignore .vagrant | ||
.vagrant | ||
*.log | ||
|
||
|
||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
class OmniauthCallbacksController < Devise::OmniauthCallbacksController | ||
def google_oauth2 | ||
account = request.env['omniauth.auth'] | ||
email = account.info.email | ||
|
||
unless User.valid_email_domain?(email) | ||
flash[:alert] = 'Email domain not valid' | ||
redirect_to new_user_session_path, event: :authentication | ||
return | ||
end | ||
|
||
@user = User.find_or_create_by_email(email) | ||
if @user && @user.deactivated_at.nil? | ||
flash[:alert] = I18n.t 'devise.omniauth_callbacks.success', kind: 'Google' | ||
sign_in_and_redirect @user, event: :authentication | ||
else | ||
flash[:alert] = 'There is something wrong, please contact the administrator' | ||
redirect_to new_user_session_path, event: :authentication | ||
end | ||
end | ||
|
||
def failure | ||
flash[:alert] = 'There is something wrong, please contact the administrator' | ||
redirect_to new_user_session_path | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class SessionsController < ApplicationController | ||
def logout | ||
sign_out current_user | ||
redirect_to root_path | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.