Configure email confirmation flow
This commit is contained in:
parent
5458c6dd8c
commit
b0124fbd26
18
app/controllers/users/confirmations_controller.rb
Normal file
18
app/controllers/users/confirmations_controller.rb
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
class Users::ConfirmationsController < Devise::ConfirmationsController
|
||||||
|
clear_respond_to
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def show
|
||||||
|
super do |resource|
|
||||||
|
if resource.errors.empty?
|
||||||
|
render json: resource, status: :ok
|
||||||
|
else
|
||||||
|
render json: {
|
||||||
|
message: 'Record invalid',
|
||||||
|
errors: resource.errors.full_messages
|
||||||
|
}, status: :unprocessable_entity
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,11 +1,14 @@
|
|||||||
# Copyright (C) 2024 Manuel Bustillo
|
# Copyright (C) 2024 Manuel Bustillo
|
||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
devise_for :users, skip: [:registration, :session, :confirmation]
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
post 'users', to: 'users/registrations#create'
|
post 'users', to: 'users/registrations#create'
|
||||||
|
|
||||||
post '/users/sign_in', to: 'users/sessions#create'
|
post '/users/sign_in', to: 'users/sessions#create'
|
||||||
delete '/users/sign_out', to: 'users/sessions#destroy'
|
delete '/users/sign_out', to: 'users/sessions#destroy'
|
||||||
|
|
||||||
|
get '/users/confirmation', to: 'users/confirmations#show', as: :confirmation
|
||||||
end
|
end
|
||||||
|
|
||||||
mount Rswag::Ui::Engine => '/api-docs'
|
mount Rswag::Ui::Engine => '/api-docs'
|
||||||
|
20
spec/requests/users/confirmations_spec.rb
Normal file
20
spec/requests/users/confirmations_spec.rb
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
require 'swagger_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'users/confirmations', type: :request do
|
||||||
|
|
||||||
|
path '/users/confirmation' do
|
||||||
|
get('confirm user email') do
|
||||||
|
tags 'Users'
|
||||||
|
produces 'application/json'
|
||||||
|
|
||||||
|
parameter name: :confirmation_token, in: :query, type: :string, required: true
|
||||||
|
|
||||||
|
response(200, 'confirmed') do
|
||||||
|
schema Swagger::Schema::USER
|
||||||
|
xit
|
||||||
|
end
|
||||||
|
|
||||||
|
response_422
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user