Sha256: bfa01903b277ba1fd35f2eb4c4015277a64720b19c66c2240a4318943b328ac3

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 KB

Contents

# require_dependency "ishapi/application_controller"

module Ishapi
  class UsersController < Ishapi::ApplicationController

    skip_authorization_check only: %i| create fb_sign_in login |


    before_action :check_profile_hard, only: %i| account |

    def account
      @profile = @current_user&.profile
      authorize! :show, @profile
      render 'ishapi/users/account'
    rescue CanCan::AccessDenied
      render json: {
        status: :not_ok,
      }, status: 401
    end

    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

    def fb_sign_in
      authorize! :fb_sign_in, Ishapi
      # render :json => { :status => :ok }
      render :action => 'show'
    end

  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
ishapi-0.1.8.194 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.193 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.192 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.191 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.190 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.189 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.188 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.187 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.185 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.184 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.183 app/controllers/ishapi/users_controller.rb
ishapi-0.1.8.182 app/controllers/ishapi/users_controller.rb