Class: FastExt::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- FastExt::SessionsController
- Defined in:
- app/controllers/fast_ext/sessions_controller.rb
Instance Method Summary collapse
-
#forgot_password ⇒ Object
assign them a random one and mail it to them, asking them to change it.
- #login ⇒ Object
- #logout ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#forgot_password ⇒ Object
assign them a random one and mail it to them, asking them to change it
36 37 38 39 40 41 42 43 |
# File 'app/controllers/fast_ext/sessions_controller.rb', line 36 def forgot_password klass = params[:type] || 'FastExt::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 |
#login ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/fast_ext/sessions_controller.rb', line 7 def login klass = params[:type] || 'FastExt::MPerson' user = klass.constantize.where(username: params[:username]).first respond_with(user) do |format| if UserAuthenticator.new(user).authenticate(params[:password]) session[:type] = user.class session[:user_id] = user.id 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 '/fast-ext' ##else # flash[:alert] = "Login failed." # render "new" #end end |
#logout ⇒ Object
31 32 33 |
# File 'app/controllers/fast_ext/sessions_controller.rb', line 31 def logout end |