Sha256: 873914f282aa1e8db427c96b98a664b715ca568af4237b7df7a1703129190110
Contents?: true
Size: 1.34 KB
Versions: 1
Compression:
Stored size: 1.34 KB
Contents
module Overrides class SessionsController < DeviseTokenAuth::SessionsController OVERRIDE_PROOF = "(^^,)" def create @resource = resource_class.find_by(email: resource_params[:email]) if @resource and valid_params?(:email, resource_params[:email]) and @resource.valid_password?(resource_params[:password]) and @resource.confirmed? # create client id @client_id = SecureRandom.urlsafe_base64(nil, false) @token = SecureRandom.urlsafe_base64(nil, false) @resource.tokens[@client_id] = { token: BCrypt::Password.create(@token), expiry: (Time.now + @resource.token_lifespan).to_i } @resource.save render json: { data: @resource.as_json(except: [ :tokens, :created_at, :updated_at ]), override_proof: OVERRIDE_PROOF } elsif @resource and not @resource.confirmed? render json: { success: false, errors: [ "A confirmation email was sent to your account at #{@resource.email}. "+ "You must follow the instructions in the email before your account "+ "can be activated" ] }, status: 401 else render json: { errors: ["Invalid login credentials. Please try again."] }, status: 401 end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
devise_token_auth-0.1.43.beta1 | test/dummy/app/controllers/overrides/sessions_controller.rb |