Class: Doodle::AuthController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Doodle::AuthController
- Defined in:
- app/controllers/doodle/auth_controller.rb
Instance Method Summary collapse
Methods inherited from ApplicationController
Instance Method Details
#auth_params ⇒ Object
15 16 17 |
# File 'app/controllers/doodle/auth_controller.rb', line 15 def auth_params @params ||= params.require(:auth).permit(:login, :password, :type) end |
#authenticate ⇒ Object
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.login, session_token: token_creator_service.token } else render json: { error: "When authenticate user" } end end |
#token_creator_service ⇒ Object
19 20 21 |
# File 'app/controllers/doodle/auth_controller.rb', line 19 def token_creator_service @creator_service ||= Layer::TokenCreatorService.new(@user.login) end |