Class: Ishapi::UsersController
Instance Method Summary
collapse
#home, #long_term_token, #vote
Instance Method Details
#account ⇒ Object
11
12
13
14
15
16
17
18
19
|
# File 'app/controllers/ishapi/users_controller.rb', line 11
def account
@profile = @current_user&.profile
authorize! :show, @profile
render 'ishapi/users/account'
rescue CanCan::AccessDenied
render json: {
status: :not_ok,
}, status: 401
end
|
#create ⇒ Object
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 'login'
else
render json: {
messages: @user.errors.messages.merge( @profile.errors.messages ),
}, status: 400
end
end
|
#fb_sign_in ⇒ Object
38
39
40
41
42
|
# File 'app/controllers/ishapi/users_controller.rb', line 38
def fb_sign_in
authorize! :fb_sign_in, Ishapi
render :action => 'show'
end
|