-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
59ca451
commit 940de3e
Showing
20 changed files
with
628 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEVISE_JWT_SECRET_KEY=2d10b194c32b63259ec1c7efbf7846f2789c947d12a77e2911109cd57f667a8e822190c7ce2fe59b874a4af918c25e88ac8f7b1690b069bb28bad4db44ee3aad |
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,17 @@ | ||
class Users::RegistrationsController < Devise::RegistrationsController | ||
respond_to :json | ||
|
||
private | ||
|
||
def respond_with(resource, _opts = {}) | ||
resource.persisted? ? register_success : register_failed | ||
end | ||
|
||
def register_success | ||
render json: { message: 'Signed up.' } | ||
end | ||
|
||
def register_failed | ||
render json: { message: "Signed up failure." } | ||
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,22 @@ | ||
class Users::SessionsController < Devise::SessionsController | ||
respond_to :json | ||
|
||
private | ||
|
||
def respond_with(resource, _opts = {}) | ||
render json: { message: 'Logged.' }, status: :ok | ||
end | ||
|
||
def respond_to_on_destroy | ||
current_user ? log_out_success : log_out_failure | ||
end | ||
|
||
def log_out_success | ||
render json: { message: "Logged out." }, status: :ok | ||
end | ||
|
||
def log_out_failure | ||
render json: { message: "Logged out failure."}, status: :unauthorized | ||
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,5 @@ | ||
class JwtDenylist < ApplicationRecord | ||
include Devise::JWT::RevocationStrategies::Denylist | ||
|
||
self.table_name = 'jwt_denylist' | ||
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,13 @@ | ||
class User < ApplicationRecord | ||
# Include default devise modules. Others available are: | ||
# :confirmable, :lockable, :timeoutable, :trackable and :omniauthable | ||
|
||
devise :database_authenticatable, | ||
:jwt_authenticatable, | ||
:trackable, | ||
:registerable, | ||
jwt_revocation_strategy: JwtDenylist | ||
|
||
# validates :username, uniqueness: { case_sensitive: false }, presence: true, allow_blank: false, format: { with: /\A[a-zA-Z0-9]+\z/ } | ||
|
||
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
Oops, something went wrong.