예제 #1
0
 public override async Task <bool> CreateUserAsync(ZNxt.Net.Core.Model.UserModel user, bool sendEmail = true)
 {
     if (user != null && !IsExists(user.user_id))
     {
         if (user.roles == null)
         {
             user.roles = new List <string>();
         }
         var roles = new List <string>()
         {
             "user", "init_user"
         };
         roles.AddRange(user.roles);
         user.roles = roles.Distinct().ToList();
         user.salt  = CommonUtility.RandomString(10);
         var userObject = JObject.Parse(JsonConvert.SerializeObject(user));
         userObject[CommonField.IS_ENABLED] = true;
         if (_dBService.WriteData(Collection.USERS, userObject))
         {
             var userInfo = new JObject();
             userInfo[CommonField.DISPLAY_ID] = CommonUtility.GetNewID();
             userInfo[CommonField.USER_ID]    = user.user_id;
             var result = _dBService.WriteData(Collection.USER_INFO, userInfo);
             if (result)
             {
                 if (sendEmail)
                 {
                     await _userNotifierService.SendWelcomeEmailAsync(user);
                 }
             }
             else
             {
                 userObject[CommonField.IS_ENABLED] = false;
                 _dBService.Write(Collection.USERS, userObject, "{user_id: '" + user.user_id + "'}");
                 _logger.Error($"Error while creating user user_id : {user.user_id} Type: {user.user_type}, email:{user.email}");
             }
             return(result);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
예제 #2
0
 public override bool CreateUser(ZNxt.Net.Core.Model.UserModel user, bool sendEmail = true)
 {
     return(CreateUserAsync(user, sendEmail).GetAwaiter().GetResult());
 }
예제 #3
0
 public abstract Task <bool> CreateUserAsync(ZNxt.Net.Core.Model.UserModel user, bool sendEmail = true);