Class: Masq::SessionsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/masq/sessions_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/masq/sessions_controller.rb', line 10

def create
  self. = Masq::Account.authenticate(params[:login], params[:password])
  if logged_in?
    flash[:notice] = t(:you_are_logged_in)
    
  else
    a = Masq::Account.find_by(login: params[:login])
    if a.nil?
      redirect_to((error: "incorrect-login"), alert: t(:login_incorrect))
    elsif a.active? && a.enabled?
      redirect_to((error: "incorrect-password"), alert: t(:password_incorrect))
    elsif !a.enabled?
      redirect_to((error: "deactivated"), alert: t(:account_deactivated))
    else
      redirect_to((resend_activation_for: params[:login]), alert: t(:account_not_yet_activated))
    end
  end
end

#destroyObject



29
30
31
32
33
34
# File 'app/controllers/masq/sessions_controller.rb', line 29

def destroy
  .forget_me
  cookies.delete(:auth_token)
  reset_session
  redirect_to(root_path, notice: t(:you_are_now_logged_out))
end

#newObject



6
7
8
# File 'app/controllers/masq/sessions_controller.rb', line 6

def new
   if logged_in?
end