Created
August 13, 2015 17:06
-
-
Save cmc333333/29d9104b926fc5d2f8eb to your computer and use it in GitHub Desktop.
This file contains hidden or 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
post '/login' do | |
redirect '/login' and return unless params[:login].present? | |
login = params[:login].strip | |
@new_user = User.new | |
if (user = User.where(email: login).first) and User.authenticate(user, params[:password]) | |
if user.service.present? | |
Event.blocked_email! login, user.service | |
erb :"account/login", locals: {blocked: user.service} | |
elsif !user.confirmed? | |
flash.now[:login] = "Your account has not been confirmed." | |
erb :"account/login" | |
else | |
log_in user | |
redirect_back_or '/' | |
end | |
else | |
flash.now[:login] = "Invalid login or password." | |
erb :"account/login" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment