public static ResponseDto ChangePassword(ChangePasswordAgentBossRequest request) { ResponseDto response = new ResponseDto(); AgentBoss agentBoss = null; string oldPasswordHash = TokenGenerator.GetHashedPassword(request.old_password, 49); try { if (!AgentBossServices.CheckAgentBoss(request.user_id, request.auth_token, response)) { MakeNouserResponse(response); return(response); } using (AgentBossDao dao = new AgentBossDao()) { agentBoss = dao.FindById(request.user_id); if (agentBoss.Password == oldPasswordHash) { agentBoss.Password = TokenGenerator.GetHashedPassword(request.new_password, 49); dao.Update(agentBoss); response.code = 0; response.has_resource = 1; response.message = MessagesSource.GetMessage("password.changed"); return(response); } } response.code = 1; response.has_resource = 0; response.message = MessagesSource.GetMessage("exception"); return(response); } catch (Exception ex) { response.MakeExceptionResponse(ex); return(response); } }
public NegotiatedContentResult <ResponseDto> PostChangePassword([FromBody] ChangePasswordAgentBossRequest request) { ResponseDto resp = AgentBossServices.ChangePassword(request); return(Content(HttpStatusCode.OK, resp)); }