jam-cloud/web/app/controllers/api_sessions_controller.rb

42 lines
1.1 KiB
Ruby
Raw Permalink Normal View History

class ApiSessionsController < ApiController
def login
user = User.authenticate(params[:email], params[:password])
if user.nil?
render :json => {}, :status => 422
else
if jkclient_agent?
user.update_progression_field(:first_ran_client_at)
end
@session_only_cookie = !jkclient_agent? && 0 == params[:remember_me].to_i
complete_sign_in(user, redirect=false)
render :json => {}, :status => :ok
end
end
2024-09-25 05:11:33 +00:00
2024-09-28 16:41:48 +00:00
#update password token. inteanded for the react app (spa)
2024-09-25 05:11:33 +00:00
def request_reset_password
begin
2025-02-14 14:14:20 +00:00
User.reset_password(params[:email], APP_CONFIG.spa_origin_url)
2024-09-25 16:49:50 +00:00
render :json => {}, :status => 204
2024-09-25 05:11:33 +00:00
rescue JamRuby::JamArgumentError
render :json => {:message => ValidationMessages::EMAIL_NOT_FOUND}, :status => 403
end
2024-09-25 16:49:50 +00:00
2024-09-25 05:11:33 +00:00
end
2024-09-28 16:41:48 +00:00
def reset_forgot_password
begin
User.set_password_from_token(params[:email], params[:token], params[:password], params[:password_confirmation])
render :json => {}, :status => 204
rescue JamRuby::JamArgumentError => e
render :json => {:message => e.field_message}, :status => 403
end
end
end