mirror of
https://github.com/fspc/BikeShed-1.git
synced 2025-04-04 05:33:22 -04:00
-Checkin/out api methods can be used while signed in -Added checkout button in Netzke App, which also signs out in addition to checking out.
23 lines
601 B
Ruby
23 lines
601 B
Ruby
class Api::V1::BaseController < ActionController::Base
|
|
respond_to :json
|
|
|
|
before_filter :authenticate_user
|
|
|
|
private
|
|
def authenticate_user
|
|
if params[:username]
|
|
user = User.find_for_database_authentication( :email => params[:username] )
|
|
@current_user = user if user && user.valid_password?( params[:password] )
|
|
|
|
if @current_user.nil?
|
|
msg = "Username/Password/Token invalid"
|
|
render :json => {:error => msg }, :status => 403 and return
|
|
end
|
|
else
|
|
authenticate_user!
|
|
@current_user = current_user
|
|
end
|
|
end
|
|
end
|
|
|