@@ -9,6 +9,8 @@ import axios from 'axios';
9
9
import { get , omit , pick , uniqBy } from 'lodash' ;
10
10
import DbService from 'moleculer-db' ;
11
11
import MongoDBAdapter from 'moleculer-db-adapter-mongo' ;
12
+ import { v4 as uuidv4 } from 'uuid' ;
13
+
12
14
13
15
const Auth = require ( '@libs-private/service-logic/mixins/auth' ) ;
14
16
@@ -429,8 +431,7 @@ module.exports = {
429
431
verified : get ( user , 'verified_email' , false )
430
432
} ] ;
431
433
432
- // Google doesn't provide username, so we'll create one from email.
433
- const username = email . split ( '@' ) [ 0 ] ;
434
+ const username = `${ email . split ( '@' ) [ 0 ] } -${ uuidv4 ( ) . replace ( / - / g, '' ) . substring ( 0 , 16 ) } ` ;
434
435
435
436
// Google provides given_name and family_name directly
436
437
const firstName = get ( user , 'given_name' , '' ) ;
@@ -587,7 +588,7 @@ module.exports = {
587
588
)
588
589
: null ;
589
590
590
- const username = get ( user , 'login' ) ;
591
+ const username = ` ${ get ( user , 'login' ) } - ${ uuidv4 ( ) . replace ( / - / g , '' ) . substring ( 0 , 16 ) } ` ;
591
592
592
593
const [ firstName , lastName ] = getFirstAndLastNameFromName (
593
594
get ( user , 'name' )
@@ -695,7 +696,7 @@ module.exports = {
695
696
} ,
696
697
] ;
697
698
698
- const username = get ( user , 'username' ) ;
699
+ const username = ` ${ get ( user , 'username' ) } - ${ uuidv4 ( ) . replace ( / - / g , '' ) . substring ( 0 , 16 ) } ` ;
699
700
700
701
const [ firstName , lastName ] = getFirstAndLastNameFromName (
701
702
get ( user , 'name' )
0 commit comments