Class: Fastui::SessionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#paginate

Instance Method Details

#forgot_passwordObject

assign them a random one and mail it to them, asking them to change it



33
34
35
36
37
38
39
40
# File 'app/controllers/fastui/sessions_controller.rb', line 33

def forgot_password
  klass = params[:type] || 'Fastui::MPerson'
  @user = klass.constantize.where(username:params[:username])
  random_password = Array.new(10).map { (65 + rand(58)).chr }.join
  @user.password = random_password
  @user.save!
  #Mailer.create_and_deliver_password_change(@user, random_password)
end

#loginObject



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

def 
  klass = params[:type] || 'Fastui::MPerson'
  user = klass.constantize.where(username: params[:username]).first

  respond_with(user) do |format|
    if UserAuthenticator.new(user).authenticate(params[:password])
      format.json { render :json => {:success => true, :msg => 'ok'} }
    else
      format.json { render :json => {:success => false, :msg => 'false'} }
    end
  end

  #if UserAuthenticator.new(user).authenticate(params[:password])
  #  #self.current_user = user
  #  redirect_to '/fastui'
  ##else
  #  flash[:alert] = "Login failed."
  #  render "new"
  #end

end

#logoutObject



28
29
30
# File 'app/controllers/fastui/sessions_controller.rb', line 28

def logout

end