-
-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace Devise with has_secure_password (#992)
* Remove Devise & related configuration/files that are not used or unneeded * Rename devise styles to login (not used yet) Also remove use of devise-ish styles that are never used from onboarding. * Use has_secure_password --------- Co-authored-by: Laura Mosher <[email protected]>
- Loading branch information
1 parent
e0dbdd6
commit 687abea
Showing
34 changed files
with
122 additions
and
561 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
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
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 |
---|---|---|
|
@@ -130,10 +130,6 @@ | |
.logo { | ||
display: none; | ||
} | ||
|
||
.devise-card { | ||
margin-bottom: 0; | ||
} | ||
} | ||
|
||
&-links { | ||
|
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
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,27 @@ | ||
module Sessions::Helpers | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
helper_method :current_user | ||
helper_method :user_signed_in? | ||
end | ||
|
||
def authenticate_user! | ||
if !user_signed_in? | ||
flash[:alert] = t("devise.failure.unauthenticated") | ||
redirect_to login_path | ||
end | ||
end | ||
|
||
private | ||
|
||
def user_signed_in? | ||
current_user.present? | ||
end | ||
|
||
# Define the current_user method: | ||
def current_user | ||
# Look up the current user based on user_id in the session cookie: | ||
@current_user ||= User.find(session[:user_id]) if session[:user_id] | ||
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
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 was deleted.
Oops, something went wrong.
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,35 @@ | ||
class SessionsController < ApplicationController | ||
skip_before_action :authenticate_user! | ||
|
||
def new | ||
# render login form | ||
end | ||
|
||
# Create session | ||
def create | ||
user = User.where(username: login_params[:login]).or(User.where(email: login_params[:login])).first | ||
|
||
if session[:user_id] == user&.id | ||
redirect_to root_path, notice: t("devise.failure.already_authenticated") | ||
elsif user.authenticate(login_params[:password]) | ||
session[:user_id] = user.id | ||
user.update_tracked_fields(request) | ||
redirect_to root_path, notice: t("devise.sessions.signed_in") | ||
else | ||
flash.now.alert = t("devise.failure.not_found_in_database", authentication_keys: "login") | ||
render :new | ||
end | ||
end | ||
|
||
# Delete sessions | ||
def destroy | ||
session.delete(:user_id) | ||
redirect_to login_path, notice: t("devise.sessions.signed_out") | ||
end | ||
|
||
private | ||
|
||
def login_params | ||
params.require(:user).permit(:login, :password) | ||
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
5 changes: 0 additions & 5 deletions
5
rails/app/views/devise/mailer/confirmation_instructions.html.erb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
rails/app/views/devise/mailer/reset_password_instructions.html.erb
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.