-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add reset password flow #441
Open
leonardobrito
wants to merge
4
commits into
main
Choose a base branch
from
440-reset-password-flow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
SERVER_HOST=localhost | ||
PASSWORD_RESET_URL=http://127.0.0.1:3000 | ||
PASSWORD_RESET_URL=http://localhost:3000/auth/reset_password | ||
SENDGRID_API_KEY= | ||
AWS_ACCESS_KEY_ID= | ||
AWS_SECRET_ACCESS_KEY= | ||
S3_BUCKET_NAME= | ||
AWS_BUCKET_REGION= | ||
LAUNCHY_DRY_RUN=true | ||
BROWSER=/dev/null |
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,2 @@ | ||
// require_self | ||
// require_tree. |
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,2 @@ | ||
//= require jquery | ||
//= require jquery_ujs |
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 @@ | ||
//= require_self | ||
|
||
$(document).ready(function () { | ||
$('#reset_password_form').submit(function (event) { | ||
event.preventDefault(); | ||
|
||
const params = $(this).data('params') | ||
|
||
const headers = { | ||
uid: params.uid, | ||
client: params.client, | ||
'access-token': params['access-token'] | ||
} | ||
|
||
$.ajax({ | ||
headers, | ||
url: $(this).attr('action'), | ||
type: "PUT", | ||
datatype: "application/js", | ||
data: $(this).serialize(), | ||
success: function (response) { | ||
alert(response.message) | ||
}, | ||
error: function (_XMLHttpRequest, textStatus, errorThrown) { | ||
alert("Status: " + textStatus); alert("Error: " + errorThrown); | ||
} | ||
}) | ||
|
||
return false; | ||
}); | ||
}) |
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 @@ | ||
class AuthController < ApplicationController | ||
def reset_password; end | ||
|
||
private | ||
|
||
def auth_params | ||
params.permit('access-token', :client, :client_id, :token, :uid) | ||
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,19 @@ | ||
<%= javascript_include_tag "jquery_init" %> | ||
<%= javascript_include_tag "reset_password", "data-turbolinks-track" => true %> | ||
|
||
<div style="margin: auto; width: 50%; height: 50%; padding: 10px;"> | ||
<h2>Reset your password</h2> | ||
|
||
<%= form_with url: user_password_path, | ||
local: false, method: :put, html: { id: "reset_password_form", data: { params: params} } do |form| %> | ||
<div class="field"> | ||
<%= form.label :password %> | ||
<%= form.password_field :password %> | ||
</div> | ||
<div class="field"> | ||
<%= form.label :password_confirmation %> | ||
<%= form.password_field :password_confirmation %> | ||
</div> | ||
<%= form.submit 'Reset Password', style: 'margin-top: 24px; padding: 12px;' %> | ||
<% end %> | ||
</div> |
5 changes: 5 additions & 0 deletions
5
backend-rails/app/views/devise/mailer/confirmation_instructions.html.erb
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 @@ | ||
<p><%= t(:welcome).capitalize + ' ' + @email %>!</p> | ||
|
||
<p><%= t '.confirm_link_msg' %> </p> | ||
|
||
<p><%= link_to t('.confirm_account_link'), user_confirmation_url(@resource, {confirmation_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url']}).html_safe %></p> |
8 changes: 8 additions & 0 deletions
8
backend-rails/app/views/devise/mailer/reset_password_instructions.html.erb
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 @@ | ||
<p><%= t(:hello).capitalize %> <%= @resource.email %>!</p> | ||
|
||
<p><%= t '.request_reset_link_msg' %></p> | ||
|
||
<p><%= link_to t('.password_change_link'), edit_user_password_url(@resource, reset_password_token: @token, config: message['client-config'].to_s, redirect_url: message['redirect-url'].to_s).html_safe %></p> | ||
|
||
<p><%= t '.ignore_mail_msg' %></p> | ||
<p><%= t '.no_changes_msg' %></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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>My App</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<%= csrf_meta_tags %> | ||
<%= csp_meta_tag %> | ||
|
||
<%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> | ||
<%= javascript_include_tag "application", "data-turbo-track": "reload", defer: true %> | ||
</head> | ||
|
||
<body> | ||
<%= yield %> | ||
</body> | ||
</html> |
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 |
---|---|---|
|
@@ -42,9 +42,12 @@ | |
# Don't care if the mailer can't send. | ||
config.action_mailer.raise_delivery_errors = true | ||
config.action_mailer.delivery_method = :letter_opener | ||
|
||
config.action_mailer.perform_deliveries = true | ||
config.action_mailer.default_options = { from: '[email protected]' } | ||
config.action_mailer.perform_caching = false | ||
|
||
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 } | ||
|
||
# Print deprecation notices to the Rails logger. | ||
config.active_support.deprecation = :log | ||
|
||
|
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,7 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe 'Auths', type: :request do | ||
describe 'GET /index' do | ||
pending "add some examples (or delete) #{__FILE__}" | ||
end | ||
end |
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.
Please delete or update this spec
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.
Done here: 208b318