1
0
mirror of https://github.com/sasjs/adapter.git synced 2026-01-08 04:50:06 +00:00

fix(auth): login and check session returns username + user full name

This commit is contained in:
Saad Jutt
2022-09-25 01:11:22 +05:00
parent 2cbba38af5
commit a1c09ec802
4 changed files with 79 additions and 58 deletions

View File

@@ -5,11 +5,11 @@
const dictionary = ['Log Off']
/**
* Extracts username assuming the first word after "title" means log off if not found otherwise in the dictionary
* Extracts user full name assuming the first word after "title" means log off if not found otherwise in the dictionary
* @param response SAS response content
* @returns username
* @returns user full name
*/
export const extractUserNameSas9 = (response: string) => {
export const extractUserLongNameSas9 = (response: string) => {
const regex = /"title":\s?".*?"/
const matched = response?.match(regex)
@@ -27,17 +27,5 @@ export const extractUserNameSas9 = (response: string) => {
})
//Cut only name
let username = fullName.slice(breakIndex, -1).trim()
//Create username by SAS method - first 3 chars of every word lowercase
const usernameSplit = username.split(' ')
username = usernameSplit
.map((name: string) =>
usernameSplit.length > 1
? name.slice(0, 3).toLowerCase()
: name.toLowerCase()
)
.join('')
return username
return fullName.slice(breakIndex, -1).trim()
}