|
|
@@ -9,8 +9,20 @@ class UsersController < ApplicationController |
|
|
|
|
|
|
|
def login |
|
|
|
if request.post? |
|
|
|
# do user login logic |
|
|
|
redirect_to root_url |
|
|
|
if params[:username].nil? || params[:username].empty? || |
|
|
|
params[:password].nil? || params[:password].empty? |
|
|
|
flash.now[:alert] = 'Both a character name and password are required.' |
|
|
|
render 'login' and return |
|
|
|
end |
|
|
|
user = User.find_by(name: params[:username]) |
|
|
|
if user.nil? || !user.authenticate(params[:password]) |
|
|
|
flash.now[:alert] = 'Incorrect character name or password.' |
|
|
|
render 'login' and return |
|
|
|
end |
|
|
|
|
|
|
|
flash.now[:alert] = 'Login successful.' |
|
|
|
render 'login' and return |
|
|
|
# redirect_to root_url |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
@@ -20,4 +32,10 @@ class UsersController < ApplicationController |
|
|
|
redirect_to root_url |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
def reset |
|
|
|
if request.post? |
|
|
|
# do user reset logic |
|
|
|
end |
|
|
|
end |
|
|
|
end |