forked from hackclub/api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hackclub#338 from hackclub/implement-admin-login
Admin dashboard WIP
- Loading branch information
Showing
40 changed files
with
860 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
# See V1::ApiController for base controller of API V1. | ||
class ApplicationController < ActionController::API | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 11 additions & 14 deletions
25
...llers/v1/applicant_profiles_controller.rb → ...trollers/v1/leader_profiles_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# frozen_string_literal: true | ||
|
||
module V1 | ||
class UsersController < ApiController | ||
def auth | ||
user = User.find_or_initialize_by(email: params[:email]) | ||
|
||
user.generate_login_code! | ||
|
||
if user.save | ||
ApplicantMailer.login_code(user).deliver_later | ||
|
||
render_success(user) | ||
else | ||
render_field_errors(user.errors) | ||
end | ||
end | ||
|
||
def exchange_login_code | ||
user = User.find_by(id: params[:user_id]) | ||
login_code = params[:login_code] | ||
|
||
return render_not_found unless user | ||
|
||
if !login_code.nil? && | ||
user.login_code == login_code && | ||
user.login_code_generation > (Time.current - 15.minutes) | ||
|
||
user.generate_auth_token! | ||
user.login_code = nil | ||
user.login_code_generation = nil | ||
user.save | ||
|
||
return render_success(auth_token: user.auth_token) | ||
end | ||
|
||
render_field_error(:login_code, 'invalid', 401) | ||
end | ||
end | ||
end |
Binary file not shown.
Oops, something went wrong.