Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Login with email and add option to disable some external auth provider #396

Merged
merged 11 commits into from
Dec 7, 2023
Merged
7 changes: 6 additions & 1 deletion app/controllers/login_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,14 @@ def index

# logs in a user
def create
if params[:user][:username] =~ /\A[^@\s]+@[^@\s]+\z/ #this is a regular expression to check if the input is an email or not
syphax-bouazzouni marked this conversation as resolved.
Show resolved Hide resolved
username = LinkedData::Client::Models::User.find_by_email(params[:user][:username]).first.username
else
username = params[:user][:username]
end
@errors = validate(params[:user])
if @errors.size < 1
logged_in_user = LinkedData::Client::Models::User.authenticate(params[:user][:username], params[:user][:password])
logged_in_user = LinkedData::Client::Models::User.authenticate(username, params[:user][:password])
if logged_in_user && !logged_in_user.errors
login(logged_in_user)
redirect = "/"
Expand Down
4 changes: 2 additions & 2 deletions app/views/login/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
%div.d-flex.justify-content-center.flew-wrap
- omniauth_providers_info.each do |provider, config|
= button_to "/auth/#{config[:name] || config[:strategy] || provider}",
class: 'btn btn-lg', style:'width: 70px', title: "Login with #{provider.to_s.humanize}", 'data-turbo': false do
class: 'btn btn-lg',disabled: !config[:enable] ,style:'width: 70px', title: "Login with #{provider.to_s.humanize}", 'data-turbo': false do;
syphax-bouazzouni marked this conversation as resolved.
Show resolved Hide resolved
- if config[:icon]
= inline_svg config[:icon]
- else
- else
= provider.to_s.humanize