Sha256: bf6851de92c707b136ae3f8ba477a76d969c5c735abaf60e23a28eb240124f9e

Contents?: true

Size: 920 Bytes

Versions: 7

Compression:

Stored size: 920 Bytes

Contents

class Mobile::UsersController < ApplicationController
  skip_before_filter :authenticate_user!, :only => :sign_in

  rescue_from ActiveRecord::RecordNotFound do
    error = {
      :error => "Could not sign in",
      :reason => "Organization could not be found",
      :code => 2
    }
    render :json => error, :status => 404
  end

  def sign_in
    user = User.find_by_email(params[:email])

    if user && user.valid_password?(params[:password])
      if params[:organization_id]
        now = Time.parse(params[:now]) rescue Time.zone.now
        organization = user.organizations.find(params[:organization_id])
      end

      render :json => user, :auth_token => true, :organization => organization, :now => now
    else
      error = {
        :error => "Could not sign in",
        :reason => "Invalid email/password",
        :code => 1
      }
      render :json => error, :status => 422
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
artfully_ose-1.2.0.pre.23 app/controllers/mobile/users_controller.rb
artfully_ose-1.2.0.pre.21 app/controllers/mobile/users_controller.rb
artfully_ose-1.2.0.pre.20 app/controllers/mobile/users_controller.rb
artfully_ose-1.2.0.pre.19 app/controllers/mobile/users_controller.rb
artfully_ose-1.2.0.pre.18 app/controllers/mobile/users_controller.rb
artfully_ose-1.2.0.pre.17 app/controllers/mobile/users_controller.rb
artfully_ose-1.2.0.pre.16 app/controllers/mobile/users_controller.rb