Skip to content
Snippets Groups Projects
Verified Commit 3082fef6 authored by Aishwarya Subramanian's avatar Aishwarya Subramanian :m:
Browse files

Using first and last name instead of name

Added name in permitted params
Added additional routes
Pushing temperory commit - for testing
Added fname, lname to build_service
Revert "Pushing temperory commit - for testing"
Deriving name from fname, lname
Added changelog and some additional specs
Refactored building of name attribute
parent 7d06ee80
No related branches found
No related tags found
1 merge request!15213[Backend] Add custom endpoint for new registrations
......@@ -87,7 +87,9 @@ def signup_params
:password_automatically_set,
:name,
:password,
:username
:username,
:first_name,
:last_name
]
end
......@@ -107,6 +109,10 @@ def build_user_params(skip_authorization:)
if user_params[:skip_confirmation].nil?
user_params[:skip_confirmation] = skip_user_confirmation_email_from_setting
end
if (user_params[:first_name].present? || user_params[:last_name].present?) && !user_params[:name].present?
user_params[:name] = "#{user_params[:first_name]} #{user_params[:last_name]}"
end
end
if user_default_internal_regex_enabled? && !user_params.key?(:external)
......
......@@ -5,6 +5,6 @@ class TrialRegistrationsController < RegistrationsController
private
def sign_up_params
params.require(:user).permit(:username, :email, :email_confirmation, :name, :password, :skip_confirmation)
params.require(:user).permit(:username, :email, :email_confirmation, :first_name, :last_name, :password, :skip_confirmation)
end
end
---
title: "[Backend] Add custom endpoint for trial registrations"
merge_request: 15213
author:
type: added
# frozen_string_literal: true
resources :trial_registrations, only: [:create]
resources :trial_registrations, only: [:new, :create]
# frozen_string_literal: true
require 'spec_helper'
describe TrialRegistrationsController do
......@@ -10,7 +12,8 @@
let(:user_params) do
{
name: 'John Doe',
first_name: 'John Doe',
last_name: 'Doe',
email: 'johnd2019@local.dev',
username: 'johnd',
password: 'abcd1234'
......@@ -32,5 +35,13 @@
expect(User.last).not_to be_confirmed
end
end
context 'derivation of name' do
it 'sets name from first and last name' do
post :create, params: { user: user_params }
expect(User.last.name).to eq("#{user_params[:first_name]} #{user_params[:last_name]}")
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment