-
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
43f01d3
feature: Adding adding authentication by jwt
mikeoleynik e11e918
feature: Adding ability to send an invitate
mikeoleynik 8b90bd0
feature: Adding a new user
mikeoleynik e01c889
Adding: init setup
mikeoleynik 6a03799
chore: Adding devise
mikeoleynik 7951cc4
chore: Made authentication for all controllers (transfer to Applicati…
mikeoleynik bd382a8
fix: Adding UsersController#create for create user (and send invite)
mikeoleynik 3541741
chore: Adding constraint for user fullname
mikeoleynik 945b275
chore: Adding gem faker for test
mikeoleynik 209a94b
chore: Removing default value for user fullname
mikeoleynik 2429958
chore: Adding error output when creating a default user
mikeoleynik 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
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,24 +1,13 @@ | ||
# README | ||
## Getting Started | ||
|
||
This README would normally document whatever steps are necessary to get the | ||
application up and running. | ||
This section provides quick start guide. | ||
|
||
Things you may want to cover: | ||
### Prerequisites | ||
|
||
* Ruby version | ||
- [Ruby](https://www.ruby-lang.org/en/): 2.6.3 | ||
- [Ruby on Rails](https://rubyonrails.org/): 2.6.3 | ||
- [PostgreSQL](https://www.postgresql.org/) 9.4 or higher. | ||
|
||
* System dependencies | ||
### Standard Installation | ||
|
||
* Configuration | ||
|
||
* Database creation | ||
|
||
* Database initialization | ||
|
||
* How to run the test suite | ||
|
||
* Services (job queues, cache servers, search engines, etc.) | ||
|
||
* Deployment instructions | ||
|
||
* ... | ||
1. `bin/setup` |
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 | ||
|
||
class ApplicationController < ActionController::API | ||
before_action :authenticate_user! | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# frozen_string_literal: true | ||
|
||
class HomeController < ApplicationController | ||
# GET / | ||
def homepage | ||
render json: { success: 'ok' }, status: :ok | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class UsersController < ApplicationController | ||
# POST /users | ||
def create | ||
User.invite!(email: '[email protected]', fullname: 'John Doe') | ||
render json: { success: 'invite sent' }, status: :ok | ||
end | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
class User < ApplicationRecord | ||
devise :database_authenticatable, :invitable, | ||
:recoverable, :rememberable, :validatable | ||
|
||
validates :email, :password, presence: true | ||
validates :email, uniqueness: true | ||
validates :password, length: { in: 8..20 } | ||
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
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,19 @@ | ||
# frozen_string_literal: true | ||
|
||
Devise.setup do |config| | ||
config.invite_for = 1.weeks | ||
config.mailer_sender = '[email protected]' | ||
|
||
require 'devise/orm/active_record' | ||
|
||
config.case_insensitive_keys = [:email] | ||
config.strip_whitespace_keys = [:email] | ||
config.skip_session_storage = [:http_auth] | ||
config.stretches = Rails.env.test? ? 1 : 11 | ||
config.reconfirmable = true | ||
config.expire_all_remember_me_on_sign_out = true | ||
config.password_length = 6..128 | ||
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/ | ||
config.reset_password_within = 6.hours | ||
config.sign_out_via = :delete | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n | ||
|
||
en: | ||
devise: | ||
confirmations: | ||
confirmed: "Your email address has been successfully confirmed." | ||
send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." | ||
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." | ||
failure: | ||
already_authenticated: "You are already signed in." | ||
inactive: "Your account is not activated yet." | ||
invalid: "Invalid %{authentication_keys} or password." | ||
locked: "Your account is locked." | ||
last_attempt: "You have one more attempt before your account is locked." | ||
not_found_in_database: "Invalid %{authentication_keys} or password." | ||
timeout: "Your session expired. Please sign in again to continue." | ||
unauthenticated: "You need to sign in or sign up before continuing." | ||
unconfirmed: "You have to confirm your email address before continuing." | ||
mailer: | ||
confirmation_instructions: | ||
subject: "Confirmation instructions" | ||
reset_password_instructions: | ||
subject: "Reset password instructions" | ||
unlock_instructions: | ||
subject: "Unlock instructions" | ||
email_changed: | ||
subject: "Email Changed" | ||
password_change: | ||
subject: "Password Changed" | ||
omniauth_callbacks: | ||
failure: "Could not authenticate you from %{kind} because \"%{reason}\"." | ||
success: "Successfully authenticated from %{kind} account." | ||
passwords: | ||
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." | ||
send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." | ||
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." | ||
updated: "Your password has been changed successfully. You are now signed in." | ||
updated_not_active: "Your password has been changed successfully." | ||
registrations: | ||
destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." | ||
signed_up: "Welcome! You have signed up successfully." | ||
signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." | ||
signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." | ||
signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." | ||
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." | ||
updated: "Your account has been updated successfully." | ||
updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again" | ||
sessions: | ||
signed_in: "Signed in successfully." | ||
signed_out: "Signed out successfully." | ||
already_signed_out: "Signed out successfully." | ||
unlocks: | ||
send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." | ||
send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." | ||
unlocked: "Your account has been unlocked successfully. Please sign in to continue." | ||
errors: | ||
messages: | ||
already_confirmed: "was already confirmed, please try signing in" | ||
confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" | ||
expired: "has expired, please request a new one" | ||
not_found: "not found" | ||
not_locked: "was not locked" | ||
not_saved: | ||
one: "1 error prohibited this %{resource} from being saved:" | ||
other: "%{count} errors prohibited this %{resource} from being saved:" |
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,31 @@ | ||
en: | ||
devise: | ||
failure: | ||
invited: "You have a pending invitation, accept it to finish creating your account." | ||
invitations: | ||
send_instructions: "An invitation email has been sent to %{email}." | ||
invitation_token_invalid: "The invitation token provided is not valid!" | ||
updated: "Your password was set successfully. You are now signed in." | ||
updated_not_active: "Your password was set successfully." | ||
no_invitations_remaining: "No invitations remaining" | ||
invitation_removed: "Your invitation was removed." | ||
new: | ||
header: "Send invitation" | ||
submit_button: "Send an invitation" | ||
edit: | ||
header: "Set your password" | ||
submit_button: "Set my password" | ||
mailer: | ||
invitation_instructions: | ||
subject: "Invitation instructions" | ||
hello: "Hello %{email}" | ||
someone_invited_you: "Someone has invited you to %{url}, you can accept it through the link below." | ||
accept: "Accept invitation" | ||
accept_until: "This invitation will be due in %{due_date}." | ||
ignore: "If you don't want to accept the invitation, please ignore this email. Your account won't be created until you access the link above and set your password." | ||
time: | ||
formats: | ||
devise: | ||
mailer: | ||
invitation_instructions: | ||
accept_until_format: "%B %d, %Y %I:%M %p" |
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,3 +1,6 @@ | ||
Rails.application.routes.draw do | ||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html | ||
devise_for :users | ||
root 'home#homepage' | ||
|
||
resources :users, only: :create | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class CreateUsers < ActiveRecord::Migration[5.2] | ||
def change | ||
create_table :users do |t| | ||
t.string :fullname, null: false, default: '' | ||
t.boolean :mentor, default: true | ||
end | ||
end | ||
end |
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.
я думаю default тут не нужен, откуда возьмется юзер без имени?