public bool SendMeOneTimePin(string username, string schoolCode, ref StringBuilder sbError) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(schoolCode) || schoolCode.Length > 200 || username.Length > 40) { return(false); } bool dbFlag = false; var parent = _uowRepository.ParentRepository.IsSchoolCodeAndEmailExist(username, schoolCode, ref dbFlag); if (!parent) { sbError.Append("email and school code does not exist , try registering your account"); return(false); } else { var isschoolExist = _uowRepository.SchoolRepository.GetSchoolByCode(schoolCode, ref dbFlag); if (isschoolExist == null) { sbError.Append("School code does not exist"); return(false); } var password = StringCommon.RandomAlphanumericString(5); var save = _uowRepository.ParentRepository.UpdateOneTimePin(username, schoolCode, password, ref dbFlag); if (save) { var message = $"Hi <br/> Please user the below one time pin " + $"<br> Password : "******" New Account ", message, ref sbError); return(true); } else { sbError.Append("Error creating account if the eror persist try contancting support"); return(false); } } return(false); }
public bool RequestNewForgotPassword(string email, string username, ref StringBuilder sbError) { if (string.IsNullOrEmpty(email)) { sbError.Append("Email does not exist for user"); return(false); } if (string.IsNullOrEmpty(username)) { sbError.Append("username does not exist"); return(false); } bool dbFlag = false; var isUserExist = _uowRepository.TeacherRepository.GetTeacherByEmail(email, ref dbFlag); if (isUserExist == null) { sbError.Append("Email does not exist"); return(false); } if (username.ToLower() != isUserExist.TeacherUsername.ToLower()) { sbError.Append("wrong account username and email"); return(false); } var onetimepin = StringCommon.RandomAlphanumericString(6); var setNewCode = _authRepository.UpdateOneTimePin((Guid)isUserExist.TeacherID, onetimepin, ref dbFlag); if (setNewCode) { var message = $"Hi {isUserExist.TeacherFullname} <br/> Please use the following One Time Pin valid for today <br/> <center><strong>Pin:</strong>{onetimepin}<center> <br/> <small>Please make sure to change your password after logging in </small>"; var sendEmail = iGrade.Core.TeacherUserService.Common.Email.SendEmail(email, "Forgot Password", message, ref sbError); return(sendEmail); } sbError.Append("Failed getting code please try again"); return(false); }
public Domain.Dto.LoggedUser LoginSessionbyToken(string token, ref StringBuilder sbError) { bool dbFlag = false; var user = _authRepository.SessionSettingByToken(token, ref dbFlag); if (user == null) { return(null); } if ( user.LastLogin.Year == DateTime.Now.Year && user.LastLogin.Month == DateTime.Now.Month && user.LastLogin.Day == DateTime.Now.Day ) { return(user); } _authRepository.UpdateLastLoginDateAndToken(user.TeacherID, StringCommon.RandomAlphanumericString(90), ref dbFlag); return(null); }