-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Authenticate/Inviting #1
Changes from 1 commit
43f01d3
e11e918
8b90bd0
e01c889
6a03799
7951cc4
bd382a8
3541741
945b275
209a94b
2429958
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,4 @@ | ||
# frozen_string_literal: true | ||
|
||
class ApplicationController < ActionController::API | ||
rescue_from BasicAuthenticate::NotAuthenticated, with: :not_authenticated | ||
|
||
private | ||
|
||
def authorize! | ||
AuthenticateByToken.new(request.headers['Authorization']).call | ||
end | ||
|
||
def not_authenticated | ||
render json: { error: 'Not Authenticated' }, status: :unauthorized | ||
end | ||
end |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class InvitesController < ApplicationController | ||
before_action :authorize! | ||
# GET /send_invite | ||
def send_invite | ||
prefix = SecureRandom.hex(3) | ||
InviteMailer.with(email: "#{prefix}[email protected]", password: 'qwerty').send_invite.deliver_later | ||
before_action :authenticate_user! | ||
|
||
# GET /invite | ||
def invite | ||
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. такое название метода не по REST. |
||
User.invite!(email: '[email protected]', fullname: 'John Doe') | ||
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. почему email захардкожен? 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. Из-за того, что логики пока никакой нет. |
||
render json: { success: 'invite sent' }, status: :ok | ||
end | ||
end |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
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.
это имеет смысл перенести в application_controller