Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 108
add new routes for frontend authentication and user flow#473
base:master
Are you sure you want to change the base?
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
a64ec0ea176f73d8481ab2f5d8e80e6c33932fe1d96ac32eb365ae2e2d273e0File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
Member 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 | ||
Member 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 | ||
| 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' | ||
Member 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:) | ||
Uh oh!
There was an error while loading. Please reload this page.
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