public SuccessWrapper <string> Login([FromBody] UserLogin login) { try { var token = UserService.CheckUserLogin(login); return(SuccessWrapper.Success(token)); } catch (Exception e) { return(SuccessWrapper.Error <string>(e)); } }
public SuccessWrapper <string> Register([FromBody] UserRegistration regInfo) { try { // detect if there are any users in the database already var firstUser = Users.Find(x => true).FirstOrDefault(); bool createAdmin = firstUser is null; var token = UserService.RegisterUser(regInfo, createAdmin); return(SuccessWrapper.Success(token)); } catch (Exception e) { return(SuccessWrapper.Error <string>(e)); } }