public IHttpActionResult Register([FromBody] RegisterDTO model) { string error = Validations.ValidateRegister(model); if (error != null) { return(BadRequest(error)); } UserAuth auth; string token; try { auth = _authManager.Register(model); if (auth == null) { return(BadRequest("Username already exists")); } token = _token.GenerateKey(auth.UserId, model.Username); _authManager.AddUserToIdentity(auth.UserId, model.Username, model.Email, token); _authManager.AddUserToSocial(auth.UserId, model.Username, token); } catch (Exception e) { _log.Error(e); return(InternalServerError()); } HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK); response.Headers.Add("x-auth-token", token); return(ResponseMessage(response)); }