2
0

feat(user): Revokable API tokens

This commit is contained in:
Baptiste Arnaud
2022-06-03 13:20:19 +02:00
parent e5d7f1d1ce
commit a0929c492b
20 changed files with 472 additions and 43 deletions

View File

@ -177,3 +177,17 @@ export const toTitleCase = (str: string) =>
/\w\S*/g,
(txt) => txt.charAt(0).toUpperCase() + txt.slice(1).toLowerCase()
)
export const generateId = (idDesiredLength: number): string => {
const getRandomCharFromAlphabet = (alphabet: string): string => {
return alphabet.charAt(Math.floor(Math.random() * alphabet.length))
}
return Array.from({ length: idDesiredLength })
.map(() => {
return getRandomCharFromAlphabet(
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
)
})
.join('')
}