This repository has been archived by the owner on Dec 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
add new routes for frontend authentication and user flow #473
Open
apex-omontgomery
wants to merge
9
commits into
master
Choose a base branch
from
user_signup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
a64ec0e
add new routes for frontend authentication and user flow
a176f73
fix undefined method for part
d8481ab
attempt other changes
2f5d8e8
attempt other changes
0e6c339
fix negative test
32fe1d9
fix the by_email route
6ac32eb
temp
365ae2e
Merge branch 'master' of https://github.com/OperationCode/operationco…
2d273e0
fix routes.rb ensure bad tests aren't running because I don't know ho…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1713,16 +1713,39 @@ API endpoints that Operation Code's Rails backend makes available to its React f | |
{ | ||
errors: "Some error message" | ||
} | ||
## User | Create [/api/v1/users{?first_name,last_name,email,zip,password,mentor}] | ||
## User | Create [/api/v1/users{?first_name,last_name,email,zip,password,bio,verified,state,address1,address2,city,username,volunteer,branch_of_service,years_of_service,pay_grade,military_occupational_speciality,github,twitter,linked_in,mentor,employment_status,education,military_status,company_role,company_name,education_level,scholarship_info,interests}] | ||
|
||
+ Parameters | ||
|
||
+ first_name (string, required) - First Name of the user in the form of an string | ||
+ last_name (string, required) - Last Name of the user in the form of an string | ||
+ email (string, required) - Email of the User in the form of a string | ||
+ zip (string, required) - Zipcode of the User in the form of a string | ||
+ first_name (string, required) - First Name of the user in the form of an string | ||
+ last_name (string, required) - Last Name of the user in the form of an string | ||
+ mentor (string, optional) - in the form of a string | ||
+ password (string, required) - Password of the User in the form on a string | ||
+ mentor (boolean, optional) - Is User requesting mentor in the form of a boolean | ||
+ bio (string, optional) - in the form of a string | ||
+ verified (string, optional) - in the form of a string | ||
+ state (string, optional) - in the form of a string | ||
+ address1 (string, optional) - in the form of a string | ||
+ address2 (string, optional) - in the form of a string | ||
+ city (string, optional) - in the form of a string | ||
+ username (string, optional) - in the form of a string | ||
+ volunteer (string, optional) - in the form of a string | ||
+ branch_of_service (string, optional) - in the form of a string | ||
+ years_of_service (string, optional) - in the form of a string | ||
+ pay_grade (string, optional) - in the form of a string | ||
+ military_occupational_speciality (string, optional) - in the form of a string | ||
+ github (string, optional) - in the form of a string | ||
+ twitter (string, optional) - in the form of a string | ||
+ linked_in (string, optional) - in the form of a string | ||
+ employment_status (string, optional) - in the form of a string | ||
+ education (string, optional) - in the form of a string | ||
+ military_status (string, optional) - in the form of a string | ||
+ company_role (string, optional) - in the form of a string | ||
+ company_name (string, optional) - in the form of a string | ||
+ education_level (string, optional) - in the form of a string | ||
+ scholarship_info (boolean, optional) - in the form of a string | ||
+ interests (string, optional) - in the form of a string | ||
|
||
### Create new user record [POST] | ||
|
||
|
@@ -1731,11 +1754,37 @@ API endpoints that Operation Code's Rails backend makes available to its React f | |
+ Body | ||
|
||
{ | ||
first_name: "Mike", | ||
last_name: "Johnson", | ||
email: "[email protected]", | ||
password: "hunter2", | ||
zip: "80020", | ||
mentor: "true" | ||
first_name: "Mike", | ||
last_name: "Johnson", | ||
bio: "Information", | ||
verified: false, | ||
state: "NC", | ||
address1: "My address", | ||
address2: "PO BOX", | ||
city: "My city", | ||
username: "mike house" | ||
volunteer: "false", | ||
branch_of_service: "Air Force", | ||
years_of_service: "100", | ||
pay_grade: "0", | ||
military_occupational_speciality: "3N", | ||
github: "user_name", | ||
twitter: "user_name", | ||
linked_in: "user_name", | ||
mentor: "true", | ||
education_level: "College Graduate", | ||
scholarship_info: "true", | ||
employment_status: "Employed", | ||
education: "BS", | ||
military_status: "spouse", | ||
company_role: "Developer", | ||
company_name: "Comcast", | ||
education_level: "BS", | ||
scholarship_info: "True", | ||
interests: "Python, Python, Python, Python" | ||
} | ||
|
||
|
||
|
@@ -1751,6 +1800,96 @@ API endpoints that Operation Code's Rails backend makes available to its React f | |
errors: "Some error message" | ||
} | ||
|
||
## User | Exists [/api/v1/users/email/{email}] | ||
|
||
+ Parameters | ||
|
||
+ email (string, required) - User email in form of a string | ||
|
||
### Checks if a user currently exists [GET] | ||
|
||
+ Request (application/json) | ||
|
||
+ Response 200 (application/json) | ||
+ Body | ||
|
||
{ | ||
status: "ok" | ||
} | ||
|
||
+ Response 422 (application/json) | ||
+ Body | ||
|
||
{ | ||
status: "Unprocessable Entity" | ||
} | ||
|
||
## User | Me [/api/v1/users{?email}] | ||
|
||
+ Parameters | ||
|
||
+ email (string, required) - Email of the User in the form of a string | ||
|
||
### Get full details for a specific user [GET] | ||
|
||
+ Request (application/json) | ||
|
||
+ Headers | ||
|
||
Authorization: Bearer Access-Token | ||
|
||
+ Response 200 (application/json) | ||
|
||
+ Body | ||
|
||
{ | ||
email: "[email protected]", | ||
zip: "80020", | ||
first_name: "Mike", | ||
last_name: "Johnson", | ||
bio: "Information", | ||
verified: false, | ||
state: "NC", | ||
address1: "My address", | ||
address2: "PO BOX", | ||
city: "My city", | ||
username: "mike house" | ||
volunteer: "false", | ||
branch_of_service: "Air Force", | ||
years_of_service: "100", | ||
pay_grade: "0", | ||
military_occupational_speciality: "3N", | ||
github: "user_name", | ||
twitter: "user_name", | ||
linked_in: "user_name", | ||
mentor: "true", | ||
education_level: "College Graduate", | ||
scholarship_info: "true", | ||
employment_status: "Employed", | ||
education: "BS", | ||
military_status: "spouse", | ||
company_role: "Developer", | ||
company_name: "Comcast", | ||
education_level: "BS", | ||
scholarship_info: "True", | ||
interests: "Python, Python, Python, Python" | ||
} | ||
|
||
+ Response 422 (application/json) | ||
|
||
+ Body | ||
|
||
{ | ||
status: "Unprocessable Entity" | ||
} | ||
|
||
+ Response 404 (application/json) | ||
|
||
{ | ||
error: 'No such record' | ||
} | ||
|
||
|
||
## User | Reset Password [/api/v1/users/passwords/reset{?email}] | ||
|
||
+ Parameters | ||
|
@@ -1798,20 +1937,39 @@ API endpoints that Operation Code's Rails backend makes available to its React f | |
{ | ||
errors: "Some error message" | ||
} | ||
## User | Update [/api/v1/users{?education_level,mentor,scholarship_info,employment_status,company_name,company_role,volunteer,military_status,branch_of_service,interests}] | ||
## User | Update [/api/v1/users{?first_name,last_name,email,zip,password,mentor,bio,verified,state,address1,address2,city,username,volunteer,branch_of_service,years_of_service,pay_grade,military_occupational_speciality,github,twitter,linked_in,employment_status,education,military_status,company_role,company_name,education_level,scholarship_info,interests}] | ||
|
||
+ Parameters | ||
|
||
+ education_level (string, optional) - Users highest level of education in the form of a string | ||
+ first_name (string, required) - First Name of the user in the form of an string | ||
+ last_name (string, required) - Last Name of the user in the form of an string | ||
+ email (string, required) - Email of the User in the form of a string | ||
+ zip (string, required) - Zipcode of the User in the form of a string | ||
+ password (string, required) - Password of the User in the form on a string | ||
+ mentor (boolean, optional) - Is User requesting mentor in the form of a boolean | ||
+ scholarship_info (boolean, optional) - Is User interested in scholarship info in the form of a boolean | ||
+ employment_status (string, optional) - Users employment status in the form of a string | ||
+ company_name (string, optional) - Users name of employer in the form on a string | ||
+ company_role (string, optional) - Users role at company in the form of a string | ||
+ volunteer (boolean, optional) - Is User wanting to volunteer in the form of a boolean | ||
+ military_status (string, optional) - Users military status, either current, veteran, spouse, or blank | ||
+ branch_of_service (string, optional) - Users branch of service in the form of a string | ||
+ interests (string, optional) - User interests in the form of a string. | ||
+ bio (string, optional) - in the form of a string | ||
+ verified (string, optional) - in the form of a string | ||
+ state (string, optional) - in the form of a string | ||
+ address1 (string, optional) - in the form of a string | ||
+ address2 (string, optional) - in the form of a string | ||
+ city (string, optional) - in the form of a string | ||
+ username (string, optional) - in the form of a string | ||
+ volunteer (string, optional) - in the form of a string | ||
+ branch_of_service (string, optional) - in the form of a string | ||
+ years_of_service (string, optional) - in the form of a string | ||
+ pay_grade (string, optional) - in the form of a string | ||
+ military_occupational_speciality (string, optional) - in the form of a string | ||
+ github (string, optional) - in the form of a string | ||
+ twitter (string, optional) - in the form of a string | ||
+ linked_in (string, optional) - in the form of a string | ||
+ employment_status (string, optional) - in the form of a string | ||
+ education (string, optional) - in the form of a string | ||
+ military_status (string, optional) - in the form of a string | ||
+ company_role (string, optional) - in the form of a string | ||
+ company_name (string, optional) - in the form of a string | ||
+ education_level (string, optional) - in the form of a string | ||
+ scholarship_info (boolean, optional) - in the form of a string | ||
+ interests (string, optional) - in the form of a string | ||
|
||
### Update user record [PATCH] | ||
|
||
|
@@ -1824,15 +1982,36 @@ API endpoints that Operation Code's Rails backend makes available to its React f | |
+ Body | ||
|
||
{ | ||
education_level: "College Graduate" , | ||
email: "[email protected]", | ||
password: "hunter2", | ||
zip: "80020", | ||
first_name: "Mike", | ||
last_name: "Johnson", | ||
bio: "Information", | ||
verified: false, | ||
state: "NC", | ||
address1: "My address", | ||
address2: "PO BOX", | ||
city: "My city", | ||
username: "mike house" | ||
volunteer: "false", | ||
branch_of_service: "Air Force", | ||
years_of_service: "100", | ||
pay_grade: "0", | ||
military_occupational_speciality: "3N", | ||
github: "user_name", | ||
twitter: "user_name", | ||
linked_in: "user_name", | ||
mentor: "true", | ||
education_level: "College Graduate", | ||
scholarship_info: "true", | ||
employment_status: "Employed", | ||
company_name: "Comcast", | ||
company_role: "Developer", | ||
education: "BS", | ||
military_status: "spouse", | ||
volunteer: "false", | ||
branch_of_service: "Air Force", | ||
company_role: "Developer", | ||
company_name: "Comcast", | ||
education_level: "BS", | ||
scholarship_info: "True", | ||
interests: "Python, Python, Python, Python" | ||
} | ||
|
||
|
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,7 +1,7 @@ | ||
module Api | ||
module V1 | ||
class UsersController < ApiController | ||
before_action :authenticate_user!, only: %i[update] | ||
before_action :authenticate_user!, only: %i[update me] | ||
|
||
def index | ||
render json: { user_count: User.count }, status: :ok | ||
|
@@ -13,7 +13,8 @@ def create | |
user = User.new(user_params) | ||
|
||
if user.save | ||
user.welcome_user | ||
user.invite_to_slack | ||
user.add_to_send_grid | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these should probably occur after |
||
UserMailer.welcome(user).deliver unless user.invalid? | ||
sign_in(user) | ||
render json: { token: user.token } | ||
|
@@ -53,6 +54,25 @@ def by_location | |
render json: { errors: e.message }, status: :unprocessable_entity | ||
end | ||
|
||
def by_email | ||
user = User.find_by(email: params[:email]) | ||
if user | ||
Rails.logger.debug "search by email successful #{request.env}" | ||
render json: { status: :ok }, status: :ok | ||
else | ||
Rails.logger.debug "search by email not found from request: #{request.env}" | ||
render json: { status: :not_found }, status: :not_found | ||
end | ||
end | ||
|
||
def me | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's happening in this method? |
||
# Rails.logger.debug "search by email for authed user email: #{current_user}" | ||
render json: ComplexUserSerializer.new(current_user), status: :ok | ||
rescue StandardError => e | ||
Rails.logger.debug "search by email errored: #{current_user} error: #{e}" | ||
render json: { status: :unprocessable_entity }, status: :unprocessable_entity | ||
end | ||
|
||
private | ||
|
||
def user_params | ||
|
@@ -68,6 +88,7 @@ def user_params | |
:state, | ||
:address1, | ||
:address2, | ||
:city, | ||
:username, | ||
:volunteer, | ||
:branch_of_service, | ||
|
@@ -84,7 +105,6 @@ def user_params | |
:company_name, | ||
:education_level, | ||
:scholarship_info, | ||
:role_id, | ||
interests: [] | ||
) | ||
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 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 |
---|---|---|
|
@@ -23,7 +23,9 @@ def initialize(subdomain:, token:) | |
end | ||
|
||
def invite(extra_message:, email:, channels: []) | ||
Rails.logger.info "Inviting user with email '#{email}'" | ||
# unsure if some string expansion is causing an error here | ||
Rails.logger.info 'Inviting slack user user' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can prolly delete this line and comment above |
||
Rails.logger.info "Inviting slack user user with email #{email}" | ||
body = send_api_request( | ||
to: INVITE_PATH, | ||
payload: { | ||
|
@@ -40,6 +42,10 @@ def invite(extra_message:, email:, channels: []) | |
end | ||
|
||
true | ||
rescue StandardError => e | ||
Rails.logger.warn "Some Exception occured while inviting slack user #{e}" | ||
# want to reraise the exception so the job retries | ||
raise | ||
end | ||
|
||
def post_message_to(channel:, with_text:) | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a boolean