Class: AuthenticationsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/authentications_controller.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Instance Method Summary collapse

Methods inherited from ApplicationController

#auto_complete

Instance Method Details

#createObject Also known as: update




23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/authentications_controller.rb', line 23

def create
  @authentication = Authentication.new(params[:authentication].permit(:username, :password, :remember_me).to_h)

  if @authentication.save && !@authentication.user.suspended?
    flash[:notice] = t(:msg_welcome)
    if @authentication.user. > 1 && @authentication.user.
      flash[:notice] += " " + t(:msg_last_login, l(@authentication.user., format: :mmddhhss))
    end
    redirect_back_or_default root_url
  else
    if @authentication.user&.awaits_approval?
      flash[:notice] = t(:msg_account_not_approved)
    else
      flash[:warning] = t(:msg_invalig_login)
    end
    redirect_to action: :new
  end
end

#destroyObject




48
49
50
51
52
# File 'app/controllers/authentications_controller.rb', line 48

def destroy
  current_user_session.destroy
  flash[:notice] = t(:msg_goodbye)
  redirect_back_or_default 
end

#newObject




13
14
15
# File 'app/controllers/authentications_controller.rb', line 13

def new
  @authentication = Authentication.new
end

#showObject




18
19
20
# File 'app/controllers/authentications_controller.rb', line 18

def show
  redirect_to 
end