edit api for login

This commit is contained in:
Sunandar
2017-01-25 11:05:06 +06:30
parent fa2b51e5e4
commit dbcee40b68
4 changed files with 40 additions and 29 deletions

View File

@@ -23,9 +23,9 @@ class Api::BatchesController < ApplicationController
session_token=params[:session_token]
batch_id=params[:batch_id]
is_authorize= Member.authenticate_session_token(session_token)
check_member= Member.authenticate_session_token(session_token)
if is_authorize
if !check_member.nil?
batch=Batch.find_by_id(batch_id)
if !batch.nil?
batch.batch_end_time = DateTime.now.beginning_of_day.utc.to_time.strftime("%Y-%m-%d")
@@ -46,28 +46,33 @@ class Api::BatchesController < ApplicationController
session_token=params[:session_token]
batch_id=params[:batch_id]
is_authorize= Member.authenticate_session_token(session_token)
if is_authorize
check_member= Member.authenticate_session_token(session_token)
if !check_member.nil?
batch=Batch.find_by_id(batch_id)
tickets=batch.tickets.count
@out=true,tickets
batch_line_items=batch.batch_line_item.count
@out=true,batch_line_items
else
@out = false, "Sorry!Unauthorized user!"
end
end
def batch_progress_list
created_by=params[:created_by]
if !created_by.nil?
batches = Batch.where('batch_end is null and created_by=?', created_by)
puts batches
if !batches.blank?
@out=true,batches
else
@out = false, "No Batch"
end
else
@out = false, "Sorry!Unauthorized user!"
end
session_token=params[:session_token]
created_by=params[:created_by]
check_member= Member.authenticate_session_token(session_token)
if !check_member.nil?
if !created_by.nil?
batches = Batch.where('batch_end is null and created_by=?', created_by)
if !batches.blank?
@out=true,batches
else
@out = false, "No Batch"
end
else
@out = false, "Sorry!Unauthorized user!"
end
else
@out = false, "Sorry!Unauthorized user!"
end
end
end