-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Implement dummy oauth integration
- Loading branch information
1 parent
f299b83
commit 04acfb2
Showing
51 changed files
with
1,285 additions
and
101 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
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,2 +1,21 @@ | ||
class ApplicationController < ActionController::Base | ||
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has. | ||
# allow_browser versions: :modern | ||
|
||
before_action :set_current_request_details | ||
# before_action :authenticate | ||
|
||
private | ||
def authenticate | ||
redirect_to sign_in_path unless Session.find_by_id(cookies.signed[:session_token]) | ||
end | ||
|
||
def set_current_request_details | ||
Current.user_agent = request.user_agent | ||
Current.ip_address = request.ip | ||
|
||
if session_record = Session.find_by_id(cookies.signed[:session_token]) | ||
Current.session = session_record | ||
end | ||
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 Authentications::EventsController < ApplicationController | ||
def index | ||
@events = Current.user.events.order(created_at: :desc) | ||
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,4 @@ | ||
class HomeController < ApplicationController | ||
def index | ||
end | ||
end |
26 changes: 26 additions & 0 deletions
26
app/controllers/identity/email_verifications_controller.rb
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,26 @@ | ||
class Identity::EmailVerificationsController < ApplicationController | ||
skip_before_action :authenticate, only: :show | ||
|
||
before_action :set_user, only: :show | ||
|
||
def show | ||
@user.update! verified: true | ||
redirect_to root_path, notice: "Thank you for verifying your email address" | ||
end | ||
|
||
def create | ||
send_email_verification | ||
redirect_to root_path, notice: "We sent a verification email to your email address" | ||
end | ||
|
||
private | ||
def set_user | ||
@user = User.find_by_token_for!(:email_verification, params[:sid]) | ||
rescue StandardError | ||
redirect_to edit_identity_email_path, alert: "That email verification link is invalid" | ||
end | ||
|
||
def send_email_verification | ||
UserMailer.with(user: Current.user).email_verification.deliver_later | ||
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,36 @@ | ||
class Identity::EmailsController < ApplicationController | ||
before_action :set_user | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @user.update(user_params) | ||
redirect_to_root | ||
else | ||
render :edit, status: :unprocessable_entity | ||
end | ||
end | ||
|
||
private | ||
def set_user | ||
@user = Current.user | ||
end | ||
|
||
def user_params | ||
params.permit(:email, :password_challenge).with_defaults(password_challenge: "") | ||
end | ||
|
||
def redirect_to_root | ||
if @user.email_previously_changed? | ||
resend_email_verification | ||
redirect_to root_path, notice: "Your email has been changed" | ||
else | ||
redirect_to root_path | ||
end | ||
end | ||
|
||
def resend_email_verification | ||
UserMailer.with(user: @user).email_verification.deliver_later | ||
end | ||
end |
Oops, something went wrong.