Class: Api::Dashboard::V2::StaffsController
Instance Method Summary
collapse
#set_options
#current_user, #identity_cache_memoization, #restaurants, #set_options
#append_info_to_payload
#check_boolean_param, #get_banners, #inventory_params, #reservation_params
#my_response_cache
Instance Method Details
#forgot_password ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/api/dashboard/v2/staffs_controller.rb', line 27
def forgot_password
return error('Email not present.', :bad_request) if staff_param[:email].blank?
staff = Staff.find_by(email: staff_param[:email])
service = PartnerService::Staff::ForgotPassword.new(staff, { reset_password_link: staff_param[:reset_password_link] })
return success('You will receive an email reset password instructions.', :ok) if service.generate_password_token!
error(I18n.t('partner.errors.staffs.not_found_email'), :not_found)
end
|
#reset_password ⇒ Object
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/api/dashboard/v2/staffs_controller.rb', line 38
def reset_password
staff = Staff.find_by(reset_password_token: staff_param[:reset_password_token])
return error('Reset token is not valid.', :bad_request) if staff.blank?
service = PartnerService::Staff::ForgotPassword.new(staff, staff_param.slice(:password, :password_confirmation))
return success('Successfully change password.', :ok) if service.reset_password!
error(staff.errors.full_messages.uniq.to_sentence, :bad_request)
end
|
#show ⇒ Object
9
10
11
12
|
# File 'app/controllers/api/dashboard/v2/staffs_controller.rb', line 9
def show
render json: ::Api::Dashboard::V2::StaffSerializer.new(current_staff,
params: { restaurant_id: @restaurant_id }).as_json
end
|
#update ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/controllers/api/dashboard/v2/staffs_controller.rb', line 14
def update
if staff_param[:first_name].present? || staff_param[:last_name].present?
params[:data][:attributes][:name] =
staff_param[:first_name].to_s.strip << ' ' << staff_param[:last_name].to_s.strip
end
if current_staff.update(staff_param)
render json: ::Api::Dashboard::V2::StaffSerializer.new(current_staff, set_options).as_json
else
render_error(current_staff, :unprocessable_entity)
end
end
|