Configure email confirmation flow
All checks were successful
Check usage of free licenses / check-licenses (pull_request) Successful in 45s
Add copyright notice / copyright_notice (pull_request) Successful in 1m7s
Run unit tests / unit_tests (pull_request) Successful in 3m38s

This commit is contained in:
Manuel Bustillo 2024-11-30 18:46:25 +01:00
parent 5458c6dd8c
commit b0124fbd26
3 changed files with 41 additions and 0 deletions

View 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

View File

@ -1,11 +1,14 @@
# Copyright (C) 2024 Manuel Bustillo
Rails.application.routes.draw do
devise_for :users, skip: [:registration, :session, :confirmation]
devise_scope :user do
post 'users', to: 'users/registrations#create'
post '/users/sign_in', to: 'users/sessions#create'
delete '/users/sign_out', to: 'users/sessions#destroy'
get '/users/confirmation', to: 'users/confirmations#show', as: :confirmation
end
mount Rswag::Ui::Engine => '/api-docs'

View 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