Ejemplo n.º 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));
     }
 }
Ejemplo n.º 2
0
 // POST tables/User
 public IHttpActionResult PostUser(RegisterRequest request)
 {
     try
     {
         string errorMessage = ValidationUtilities.ValidateUserDetails(request);
         var    domainObj    = DbUtilities.GetDomainDetails(request.Email);
         if (errorMessage.Equals(string.Empty))
         {
             string otpCode   = AuthorizationUtilities.GenerateOTPCode();
             string userEmail = HttpUtilities.GetUserNameFromToken(this.Request);
             DbUtilities.SaveTheUser(request, otpCode, domainObj, userEmail, request.IsActiveUser);
             AuthorizationUtilities.SendOTPtoUser(request.Email, otpCode);
             return(Ok(HttpUtilities.CustomResp(ErrorCodes.USER_CREATED.ToString())));
         }
         else
         {
             return(BadRequest(errorMessage));
         }
     }
     catch (Exception ex)
     {
         LGSELogger.Error(ex);
         return(InternalServerError(ex));
     }
     //return CreatedAtRoute("Tables", new { id = current.Id }, current);
 }
Ejemplo n.º 3
0
 public IHttpActionResult SignUp(RegisterRequest request)
 {
     try
     {
         string errorMessage = ValidationUtilities.ValidateUserDetails(request);
         var    domainObj    = DbUtilities.GetDomainDetails(request.Email);
         if (errorMessage.Equals(string.Empty))
         {
             string otpCode = AuthorizationUtilities.GenerateOTPCode();
             DbUtilities.SaveTheUser(request, otpCode, domainObj, request.Email, true);
             AuthorizationUtilities.SendOTPtoUser(request.Email, otpCode);
             return(Ok(HttpUtilities.CustomResp(ErrorCodes.USER_REGISTERED.ToString())));
         }
         else
         {
             return(BadRequest(errorMessage));
         }
     }
     catch (Exception ex)
     {
         LGSELogger.Error(ex);
         return(InternalServerError(ex));
     }
 }