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