Skip to content

Commit

Permalink
Replace the naive name capitalization for ESTEID voting with Postgres…
Browse files Browse the repository at this point in the history
  • Loading branch information
tiblu committed Jun 21, 2018
1 parent 91b409c commit 1489209
Showing 1 changed file with 2 additions and 24 deletions.
26 changes: 2 additions & 24 deletions routes/api/topic.js
Original file line number Diff line number Diff line change
Expand Up @@ -5304,25 +5304,10 @@ module.exports = function (app) {
})
.then(function (userConnectionInfo) {
if (!userConnectionInfo) {
var fullName = null;

// ID-card has signers first and last name, but Mobiil-ID does not. For Mobiil-ID we update the name when signing is completed.
if (personalInfo.firstName && personalInfo.lastName) {
// TODO: Basically lodash.capitalize but lodash update requires a big effort - https://trello.com/c/2mCYtfa2/266-technical-dept-upgrade-lodash-to-4-x

var firstName = personalInfo.firstName.toLowerCase();
firstName = firstName.charAt(0).toUpperCase() + firstName.slice(1);

var lastName = personalInfo.lastName.toLowerCase();
lastName = lastName.charAt(0).toUpperCase() + lastName.slice(1);

fullName = firstName + ' ' + lastName;
}

return User
.create(
{
name: fullName,
name: db.fn('initcap', personalInfo.firstName + ' ' + personalInfo.lastName),
source: User.SOURCES.citizenos
},
{
Expand Down Expand Up @@ -5847,18 +5832,11 @@ module.exports = function (app) {
);

if (!req.user) {
// TODO: Basically lodash.capitalize but lodash update requires a big effort - https://trello.com/c/2mCYtfa2/266-technical-dept-upgrade-lodash-to-4-x
var firstName = signedDocInfo.signerInfo.firstName.toLowerCase();
firstName = firstName.charAt(0).toUpperCase() + firstName.slice(1);

var lastName = signedDocInfo.signerInfo.lastName.toLowerCase();
lastName = lastName.charAt(0).toUpperCase() + lastName.slice(1);

// When starting signing with Mobile-ID we have no full name, thus we need to fetch and update
var userNameUpdatePromise = User
.update(
{
name: firstName + ' ' + lastName
name: db.fn('initcap', signedDocInfo.signerInfo.firstName + ' ' + signedDocInfo.signerInfo.lastName)
},
{
where: {
Expand Down

0 comments on commit 1489209

Please sign in to comment.