Created
February 6, 2022 10:50
-
-
Save muhammadqazi/be14c1ca550149cc694274db3b1af9f8 to your computer and use it in GitHub Desktop.
Go-Authentication
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func HandleDatabaseInsert(DBname string, CollectionName string, email string, phone int, password string, fname string, lname string, uid string, created time.Time, updated time.Time, token string, code int, agent interface{}) bool { | |
ctx, client := HandleDBConnection() | |
collection := client.Database(DBname).Collection(CollectionName) | |
_, errInsert := collection.InsertOne(ctx, bson.M{ | |
"email": email, | |
"phone": phone, | |
"password": password, | |
"first_name": fname, | |
"last_name": lname, | |
"user_id": uid, | |
"created_at": created, | |
"updated_at": updated, | |
"UserAgent": agent, | |
}) | |
HandleInsertToken(DBname, "tokens", token, code, created) | |
if errInsert != nil { | |
return false | |
} | |
defer client.Disconnect(ctx) | |
return true | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment