public void TestRetrieveTokenByPassword() { SecurityAction securityAction = new SecurityAction(ConnectString); System.Console.WriteLine(securityAction.RetrieveTokenByPassword("CR59", "Welcome-2014", "ProjectUser")); }
SecurityServiceResponse ISecurityService.RetrieveTokenByPassword(SecurityServiceRequest securityServiceRequest) { if (string.IsNullOrEmpty(securityServiceRequest.UserName) || string.IsNullOrEmpty(securityServiceRequest.CurrentPassword) || string.IsNullOrEmpty(securityServiceRequest.Type)) { return new SecurityServiceResponse() { Code = 400, Message = "Type UserName and CurrentPassword should not null" }; } if(!securityServiceRequest.Type.Equals("Administrator")&&!securityServiceRequest.Type.Equals("ProjectUser")) { return new SecurityServiceResponse() { Code = 400, Message = "Type should be Administrator or ProjectUser" }; } SecurityAction securityAction = new SecurityAction(this.ConnectString); Guid token = securityAction.RetrieveTokenByPassword(securityServiceRequest.UserName,securityServiceRequest.CurrentPassword,securityServiceRequest.Type); if(token == Guid.Empty) { return new SecurityServiceResponse() { Code = 500, Message = "Username or Password not correct" }; } return new SecurityServiceResponse() { Code = 0, Message = "Success", SecurityRequest = new SecurityRequest() { Id = securityServiceRequest.UserName, Type = securityServiceRequest.Type, Token = token.ToString() } }; }