mirror of
https://github.com/gabehf/BudgetBuddy.git
synced 2026-03-14 09:46:11 -07:00
api for initial widgets
This commit is contained in:
parent
36f751a69f
commit
4aa8a2f822
14 changed files with 864 additions and 11 deletions
|
|
@ -18,6 +18,7 @@ import (
|
|||
)
|
||||
|
||||
func CreateAccount(w http.ResponseWriter, r *http.Request) {
|
||||
log.Println("* /auth/createaccount")
|
||||
// prepare DB
|
||||
err := db.Client.Ping(context.Background(), readpref.Primary())
|
||||
if err != nil {
|
||||
|
|
@ -26,7 +27,7 @@ func CreateAccount(w http.ResponseWriter, r *http.Request) {
|
|||
var userCollection = db.Client.Database("budgetbuddy").Collection("users")
|
||||
|
||||
// var v contains POST credentials
|
||||
var v UserSchema
|
||||
var v db.UserSchema
|
||||
r.ParseForm()
|
||||
v.Email = r.FormValue("email")
|
||||
v.Password = r.FormValue("password")
|
||||
|
|
@ -72,6 +73,8 @@ func CreateAccount(w http.ResponseWriter, r *http.Request) {
|
|||
// add the new user to the database
|
||||
v.Session = sessionID
|
||||
v.Password = string(hashedPass)
|
||||
v.Balance.Currency = "USD"
|
||||
v.Budget.Currency = "USD"
|
||||
_, err = userCollection.InsertOne(r.Context(), v)
|
||||
if err != nil {
|
||||
log.Println("* Error inserting new user")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue