mirror of
https://github.com/fspc/BikeShed-1.git
synced 2026-09-16 08:31:36 -04:00
Finished Checkin/out feature for now
-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.
This commit is contained in:
@@ -5,19 +5,18 @@ class Api::V1::BaseController < ActionController::Base
|
||||
|
||||
private
|
||||
def authenticate_user
|
||||
if params[:token]
|
||||
@current_user = User.find_by_authentication_token(params[:token])
|
||||
else
|
||||
if params[:username]
|
||||
user = User.find_for_database_authentication( :email => params[:username] )
|
||||
@current_user = user if user && user.valid_password?( params[:password] )
|
||||
end
|
||||
unless @current_user
|
||||
render :json => {:error => "Username/Password/Token invalid" }, :status => 403
|
||||
end
|
||||
end
|
||||
|
||||
def current_user
|
||||
@current_user
|
||||
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
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class Api::V1::LogsController < Api::V1::BaseController
|
||||
|
||||
def checkin
|
||||
#must use @current_user since user may not have signed in
|
||||
if @current_user.checked_in?
|
||||
render :json => { "error" => "You are already checked in."}, :status => 404 and return
|
||||
else
|
||||
@@ -10,6 +11,7 @@ class Api::V1::LogsController < Api::V1::BaseController
|
||||
end
|
||||
|
||||
def checkout
|
||||
#must use @current_user since user may not have signed in
|
||||
if !@current_user.checked_in?
|
||||
render :json => { "error" => "You were not even checked in."}, :status => 404 and return
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user