1 /++ 2 A module that defines the user model 3 4 Copyright: © 2018-2020 Szabo Bogdan 5 License: Subject to the terms of the MIT license, as written in the included LICENSE.txt file. 6 Authors: Szabo Bogdan 7 +/ 8 9 module vibeauth.data.usermodel; 10 11 import vibeauth.data.token; 12 import vibe.data.json : optional; 13 import std.datetime; 14 15 /// User data used to manage an user 16 struct UserModel { 17 /// The user id 18 string _id; 19 20 @optional { 21 /// The users salutation eg. mr/ms or unset 22 string salutation; 23 24 /// The users title eg. dr 25 string title; 26 27 /// The users first name 28 string firstName; 29 30 /// The users last name 31 string lastName; 32 } 33 34 /// 35 string username; 36 37 /// The users email 38 string email; 39 40 /// The password hash 41 string password; 42 43 /// String concatenated with the pasword before hashing 44 string salt; 45 46 /// Flag used to determine if the user can perform any actions 47 bool isActive; 48 49 /// 50 @optional SysTime createdAt; 51 52 /// The timestamp of the users last activity 53 @optional ulong lastActivity; 54 55 /// Scopes that the user has access to 56 string[] scopes; 57 58 /// A list of active tokens 59 Token[] tokens; 60 61 string name() { 62 return this.firstName ~ " " ~ this.lastName; 63 } 64 65 void name(string) {} 66 }