Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object { _body: "<!DOCTYPE html> <html> <head> …", status: 500, ok: false, statusText: "Internal Server Error", headers: Object, type: 2, url: "http://ec2-52-92-174-9.us-west-2.co…" }
- // Find user in database, if exists, and log them in
- find(email:any, password:any){
- //let body:User = {email:email, password:password};
- let headers = new Headers({ 'Content-Type': 'application/json' });
- this.http.post('/api/User/find', {email:email, password:password} ,{headers:headers})
- .map(response => response.json())
- .subscribe(
- data => this.login(data),
- error => this.userError(error)
- );
- }
- public IActionResult find([FromBody] User user){
- User result = new User();
- using(SqliteConnection con = new SqliteConnection(cs)){
- con.Open();
- string stm = $"SELECT * FROM USERS WHERE EMAIL='{user.email}' AND PASSWORD='{user.password}' LIMIT 1";
- using (SqliteCommand cmd = new SqliteCommand(stm, con)){
- using (SqliteDataReader rdr = cmd.ExecuteReader()){
- while (rdr.Read()) {
- result = new User {
- id = rdr.GetInt32(0),
- email = rdr.GetString(1)
- };
- }
- }
- }
- con.Close();
- }
- if(result.Equals(user))
- return Json(result);
- return BadRequest("User not found"); // Not my current error, this is a different status 400 and message
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement