Skip to content

Commit 16f432d

Browse files
committed
API
1 parent da23e75 commit 16f432d

File tree

6 files changed

+13
-8
lines changed

6 files changed

+13
-8
lines changed

app/controllers/api/v1/breaks_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Api::V1::BreaksController < ApplicationController
2-
before_action :set_break, only: [:show, :update, :destroy]
2+
33

44
# GET /breaks
55
def index
@@ -46,6 +46,6 @@ def set_break
4646

4747
# Only allow a trusted parameter "white list" through.
4848
def break_params
49-
params.require(:break).permit(:breakdate, :breaketime, :user_id, :employee_id)
49+
params.require(:breaks).permit(:breakdate, :breaketime, :user_id, :employee_id)
5050
end
5151
end

app/controllers/api/v1/companies_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Api::V1::CompaniesController < ApplicationController
2-
before_action :set_company, only: [:show, :update, :destroy]
2+
33

44
# GET /companies
55
def index
@@ -41,7 +41,7 @@ def destroy
4141
private
4242
# Use callbacks to share common setup or constraints between actions.
4343
def set_company
44-
@company = Company.find(params[:id])
44+
@company = company.find(params[:id])
4545
end
4646

4747
# Only allow a trusted parameter "white list" through.

app/controllers/api/v1/employees_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Api::V1::EmployeesController < ApplicationController
2-
before_action :set_employee, only: [:show, :update, :destroy]
2+
33

44
# GET /employees
55
def index

app/controllers/api/v1/managers_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Api::V1::ManagersController < ApplicationController
2-
before_action :set_manager, only: [:show, :update, :destroy]
2+
33

44
# GET /managers
55
def index

app/controllers/api/v1/users_controller.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,18 @@ def login
2020
jwt = Auth.encrypt({ user_id: user.id })
2121
render json: { jwt: jwt, current: user }
2222
else
23-
render json: { error: 'Failed to Log In' }, status: 400
23+
render json: { error: 'Invalid Email or Password' }, status: 400
2424
end
2525
end
2626

2727
def show
2828
render json: get_current_user
2929
end
30+
def destroy
31+
session[:user_id] = nil
32+
@user = User.find(params[:id])
33+
@user.destroy
34+
end
3035

3136
private
3237

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
resources :breaks
1010
resources :employees
11-
11+
1212
resources :managers
1313
resources :companies
1414

0 commit comments

Comments
 (0)