Esempio n. 1
0
        async public Task <object> Login([FromBody] LoginBody body)
        {
            try {
                var user = await AuthModel.getUser(body.Email);

                if (user.Password != body.Password)
                {
                    return(Unauthorized(new { error = "Invalid password" }));
                }
                return(Ok(user));
            } catch (System.Exception e) {
                if (e.Message == "User doesn't exist")
                {
                    return(Unauthorized(new { error = "Invalid email" }));
                }
                throw e;
            }
        }