mirror of
https://github.com/arnaucube/darkID-prototype.git
synced 2026-02-07 03:16:46 +01:00
updated ethereum smart contract. Implemented backend of the login library example
This commit is contained in:
@@ -82,11 +82,21 @@ func Login(w http.ResponseWriter, r *http.Request) {
|
||||
rUser := User{}
|
||||
err = userCollection.Find(bson.M{"email": user.Email}).One(&rUser)
|
||||
if err != nil {
|
||||
} else {
|
||||
//user exists, update with the token
|
||||
err = userCollection.Update(bson.M{"_id": rUser.Id}, user)
|
||||
jResp, err := json.Marshal("error login, email not found")
|
||||
check(err)
|
||||
fmt.Fprintln(w, string(jResp))
|
||||
return
|
||||
}
|
||||
//user exists, check password
|
||||
if user.Password != rUser.Password {
|
||||
jResp, err := json.Marshal("error login, password not match")
|
||||
check(err)
|
||||
fmt.Fprintln(w, string(jResp))
|
||||
return
|
||||
}
|
||||
//update with the token
|
||||
err = userCollection.Update(bson.M{"_id": rUser.Id}, user)
|
||||
check(err)
|
||||
|
||||
jResp, err := json.Marshal(user)
|
||||
if err != nil {
|
||||
Reference in New Issue
Block a user