-
Notifications
You must be signed in to change notification settings - Fork 1
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 #1 from mikeoleynik/auth
Authenticate/Inviting
- Loading branch information
Showing
25 changed files
with
416 additions
and
69 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
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 |
Oops, something went wrong.