Class: Ishapi::UsersController

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

Overview

Cannot move this class right now - it gets hit verifying user’s account, every time. @TODO: merge with user_profiles_controller. vp 2022-10-13

Instance Method Summary collapse

Methods inherited from ApplicationController

#exception, #home, #long_term_token, #vote

Instance Method Details

#accountObject



12
13
14
15
16
17
18
19
# File 'app/controllers/ishapi/users_controller.rb', line 12

def 
  authorize! :show, @current_profile
  render 'ishapi/user_profiles/account'
rescue CanCan::AccessDenied
  render json: {
    status: :not_ok,
  }, status: 401
end

#createObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/ishapi/users_controller.rb', line 21

def create
  authorize! :open_permission, Ishapi
  new_user_params = params[:user].permit!

  @profile = Profile.new( email: new_user_params[:email] )
  @user = User.new( email: new_user_params[:email], password: new_user_params[:password], profile: @profile )

  if @profile.save && @user.save
    @jwt_token = encode(user_id: @user.id.to_s)
    render 'ishapi/user_profiles/login'
  else
    render json: {
      messages: @user.errors.messages.merge( @profile.errors.messages ),
    }, status: 400
  end
end

#fb_sign_inObject



38
39
40
41
# File 'app/controllers/ishapi/users_controller.rb', line 38

def 
  authorize! :fb_sign_in, Ishapi
  render 'ishapi/user_profiles/show'
end