Class: Doodle::AuthController

Inherits:
ApplicationController show all
Defined in:
app/controllers/doodle/auth_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_user

Instance Method Details

#auth_paramsObject



15
16
17
# File 'app/controllers/doodle/auth_controller.rb', line 15

def auth_params
  @params ||= params.require(:auth).permit(:login, :password, :type)
end

#authenticateObject



5
6
7
8
9
10
11
12
13
# File 'app/controllers/doodle/auth_controller.rb', line 5

def authenticate
  @user = User.where(password: auth_params[:password], login: auth_params[:login], type: auth_params[:type]).first

  if @user.present?
    render json: { id: @user.id, login: @user., session_token: token_creator_service.token }
  else
    render json: { error: "When authenticate user" }
  end
end

#token_creator_serviceObject



19
20
21
# File 'app/controllers/doodle/auth_controller.rb', line 19

def token_creator_service
  @creator_service ||= Layer::TokenCreatorService.new(@user.)
end