summary refs log tree commit diff
path: root/src/dto/auth/WhoAmIDto.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/dto/auth/WhoAmIDto.js')
-rw-r--r--src/dto/auth/WhoAmIDto.js26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/dto/auth/WhoAmIDto.js b/src/dto/auth/WhoAmIDto.js
new file mode 100644

index 0000000..ae1795a --- /dev/null +++ b/src/dto/auth/WhoAmIDto.js
@@ -0,0 +1,26 @@ +import { SafeNSoundError } from '#util/error.js'; +import Joi from 'joi'; + +/** + * Generic authentication DTO. + */ +export class WhoAmIDto { + userId; + username; + deviceId; + + /** + * @param data {WhoAmIDto} + * @returns {Promise<WhoAmIDto>} + */ + static async create(data) { + const obj = new WhoAmIDto(); + for (const key of Object.keys(data)) { + if (key in obj) { + obj[key] = data[key]; + } + } + + return obj; + } +}