Skip to content
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

Fixes and enhacements reset password endpoints #1

Merged
merged 2 commits into from
Aug 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions app/controllers/concerns/rack_session_fix_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module RackSessionFixController
extend ActiveSupport::Concern

class FakeRackSession < Hash
def enabled?
false
end
end

included do
before_action :set_fake_rack_session_for_devise

private

def set_fake_rack_session_for_devise
request.env['rack.session'] ||= FakeRackSession.new
end
end
end
24 changes: 23 additions & 1 deletion app/controllers/users/authentication.http
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,26 @@ Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIyMiIsInNjcCI6InVzZXIiLCJhd

### Delete User Account ###
DELETE http://localhost:3000/users
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIyMiIsInNjcCI6InVzZXIiLCJhdWQiOm51bGwsImlhdCI6MTY5MTk2MTQwNywiZXhwIjoxNjkxOTYxNzA3LCJqdGkiOiJiZDM3MzZiMi1mYTE3LTRiYzYtYjZmZS03MWMyMDlhOTdmZDQifQ.WhiAMuPRJNR2C9wr2hZ5Ma5Yc-fbk1iIuaB0cXGLGfc
Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiIyMiIsInNjcCI6InVzZXIiLCJhdWQiOm51bGwsImlhdCI6MTY5MTk2MTQwNywiZXhwIjoxNjkxOTYxNzA3LCJqdGkiOiJiZDM3MzZiMi1mYTE3LTRiYzYtYjZmZS03MWMyMDlhOTdmZDQifQ.WhiAMuPRJNR2C9wr2hZ5Ma5Yc-fbk1iIuaB0cXGLGfc

### Recover password email ###
POST http://localhost:3000/users/password
Content-Type: application/json

{
"user": {
"email": "[email protected]"
}
}

### Recover password ###
PATCH http://localhost:3000/users/password
Content-Type: application/json

{
"user": {
"reset_password_token": "CkzYfzUACpnzjnEyvSyo",
"password": "1111ilovemaristas24A###",
"password_confirmation": "1111ilovemaristas24A###"
}
}
3 changes: 3 additions & 0 deletions app/controllers/users/passwords_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Users::PasswordsController < Devise::PasswordsController
include RackSessionFixController
end
3 changes: 2 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
devise_for :users,
controllers: {
sessions: 'users/sessions',
registrations: 'users/registrations'
registrations: 'users/registrations',
passwords: 'users/passwords'
}
end