public async Task <dynamic> ChangePassword([FromBody] ValidateLoginUsersAddRequest validateloginuser) { UpdateLoginUsersResponse registrationResponse = new UpdateLoginUsersResponse(); var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString()); BulkData loginusers = JsonConvert.DeserializeObject <BulkData>(response); var UpdatedLoginDetails = loginusers.rows.FirstOrDefault(a => a.doc.Username == validateloginuser.Username); HashSalt hashSalt = Helper.GenerateSaltedHash(64, validateloginuser.Password); LoginUsers loginuser = new LoginUsers(); loginuser.Username = UpdatedLoginDetails.doc.Username; loginuser.Password = hashSalt.Hash; loginuser.Passwordsalt = hashSalt.Salt; loginuser._id = UpdatedLoginDetails.doc._id; loginuser.Id = UpdatedLoginDetails.doc.Id; loginuser.EmailID = UpdatedLoginDetails.doc.EmailID; loginuser.Type = UpdatedLoginDetails.doc.Type; loginuser._rev = UpdatedLoginDetails.doc._rev; if (_postUserLoginProcessor != null) { return(await _putUserLoginProcessor.PutExistingUserRecord(loginuser, _cloudantService)); } else { return(new string[] { "No database connection" }); } }
public async Task <UpdateLoginUsersvalidateResponse> PostLogin([FromBody] ValidateLoginUsersAddRequest validateloginuser) { var response = await _cloudantService.GetAllAsync(DBNames.loginusers.ToString()); BulkData loginusers = JsonConvert.DeserializeObject <BulkData>(response); //if (validateloginuser.Username != null) //{ var User = loginusers.rows.FirstOrDefault(a => a.doc.Username == validateloginuser.Username); var validateuser = loginusers.rows.FirstOrDefault(a => a.doc.Username == validateloginuser.Username);// && a.doc.Password == validateloginuser.Password); bool isPasswordMatched = Helper.VerifyPassword(validateloginuser.Password, User.doc.Password, User.doc.Passwordsalt); if (isPasswordMatched) { var responsetype = await _cloudantService.GetAllAsync(DBNames.userrights.ToString()); BulkDataUserRights userrights = JsonConvert.DeserializeObject <BulkDataUserRights>(responsetype); var usertyperesponse = userrights.rows.FirstOrDefault(a => a.doc.logintypes == validateuser.doc.Type); UpdateLoginUsersvalidateResponse validloginuser = new UpdateLoginUsersvalidateResponse(); validloginuser.logintypes = usertyperesponse.doc.logintypes; validloginuser.EmployeeMaster = usertyperesponse.doc.EmployeeMaster; validloginuser.ILCMaster = usertyperesponse.doc.ILCMaster; validloginuser.ForcastMaster = usertyperesponse.doc.ForcastMaster; validloginuser.Financials = usertyperesponse.doc.Financials; validloginuser.Reports = usertyperesponse.doc.Reports; validloginuser.LoginMaster = usertyperesponse.doc.LoginMaster; validloginuser.Id = usertyperesponse.doc._id; validloginuser.Rev = usertyperesponse.doc._rev; usertyperesponse.doc.ok = "Success"; validloginuser.ok = usertyperesponse.doc.ok; //validloginuser.lateston = usertyperesponse.doc.lateston; return(validloginuser); } else { UpdateLoginUsersvalidateResponse validloginuser = new UpdateLoginUsersvalidateResponse(); validloginuser.ok = "Wrong Password"; return(validloginuser); } //UpdateLoginUsersvalidateResponse validloginuser = new UpdateLoginUsersvalidateResponse(); //validloginuser.ok = "Invalid user name"; //return validloginuser; //} }