public string Signup(string username, string pwd, string name, string email, bool autoSignin) { if (string.IsNullOrWhiteSpace(username)) { throw new WebFaultException <string>("用户名不能为空", HttpStatusCode.BadRequest); } if (string.IsNullOrWhiteSpace(pwd)) { throw new WebFaultException <string>("密码不能为空", HttpStatusCode.BadRequest); } if (string.IsNullOrWhiteSpace(name)) { throw new WebFaultException <string>("姓名不能为空", HttpStatusCode.BadRequest); } User user = new User(); user.Username = username; user.Pwd = pwd; user.Name = name; user.Email = email; user.Creation = DateTime.Now; user.Modification = DateTime.Now; user.Id = Guid.NewGuid().ToString(); try { this.userService.SaveUser(user); string userToken = credentialsProvider.GenerateUserToken(username); if (autoSignin) { clientManager.AddClient(username, userToken); } return(userToken); } catch (Exception ex) { throw ExceptionHelper.Replace(ex); } }