Class: Ishapi::UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Ishapi::UsersController
- Defined in:
- app/controllers/ishapi/users_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#account ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'app/controllers/ishapi/users_controller.rb', line 10 def account @profile = current_user&.profile :show, @profile render 'ishapi/users/account' rescue CanCan::AccessDenied render json: { status: :not_ok, }, status: 401 end |
#fb_sign_in ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/ishapi/users_controller.rb', line 20 def fb_sign_in :fb_sign_in, Ishapi # render :json => { :status => :ok } render :action => 'show' end |
#login ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/ishapi/users_controller.rb', line 26 def login @current_user = User.where( email: params[:email] ).first if !@current_user render json: { status: :not_ok }, status: 401 return end if @current_user.valid_password?(params[:password]) # from: application_controller#long_term_token # send the jwt to client @jwt_token = encode(user_id: @current_user.id.to_s) @profile = @current_user.profile =begin render json: { email: @current_user.email, jwt_token: @jwt_token, n_unlocks: @current_user.profile.n_unlocks, } =end end end |