Пример #1
0
 public IHttpActionResult SendActivationLink(SendActivationReq req)
 {
     try
     {
         string currentUsrEmail = HttpUtilities.GetUserNameFromToken(this.Request);
         var    user            = _context.Users.FirstOrDefault(i => i.Id == req.UserId);
         if (user.IsActiveUser == false)
         {
             return(BadRequest(ErrorCodes.USER_DEACTIVATED_BY_ADMIN.ToString()));
         }
         else if (user.Domain.IsActive == false)
         {
             return(BadRequest(ErrorCodes.DOMAIN_IS_INACTIVE.ToString()));
         }
         ValidationUtilities.ValidateUserforActivationLink(req.UserId, user);
         string otpCode = AuthorizationUtilities.GenerateOTPCode();
         AuthorizationUtilities.SendOTPtoUser(user.Email, otpCode);
         user.OTPCode        = otpCode;
         user.OTPGeneratedAt = DateTimeOffset.UtcNow;
         user.ModifiedBy     = currentUsrEmail;
         // user.UpdatedAt = DateTimeOffset.UtcNow;
         _context.Entry(user).State = System.Data.Entity.EntityState.Modified;
         _context.SaveChanges();
         return(Ok());
     }
     catch (HttpResponseException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         LGSELogger.Error(ex);
         return(InternalServerError(ex));
     }
 }