diff --git a/src/README.md b/src/README.md index b2c101c..5078b8b 100644 --- a/src/README.md +++ b/src/README.md @@ -1,20 +1,33 @@ # WIP This is a simple webapp I use to track expenses. It has many holes and things -that don't work properly. I use this README internally to keep in mind what -I'm working on. +that don't work properly, but the current feature set is: +- Users (Authentication) +- Multiple APIs: Lua API, REST API that returns JSON and of course the core +`expenses` package itself that can be used separately +- Insert expenses via QR code (at least the data that is available, am working +on making the experience as seamless as possible) +- Share expenses arbitrarily with others +- Check the balance on your own expenses + + +There are many features to be implemented! # BUGS -Inserting an expense where the owner has no payments results in a panic +- Inserting an expense where the owner has no payments results in a panic # DOING -- Auth # TODO -- [ ] Users/Authentication/Autherization -- [ ] API +- [X] Users/Authentication +- [ ] Authorization +- [X] API (not complete, but going) +- [ ] Add more logging (and configure the logger) +- [ ] Need to add many UTs +- [ ] Need to think about where the authentication endpoints are its separation +of concerns - [ ] Create an interface to get data from a QR code so that we can have both a web API and our go package - [ ] If unable to connect to the database, try again, after X seconds @@ -36,6 +49,7 @@ used - [X] Rename this file - [ ] Better UX when adding expenses on the payments and share values (default even split) - [ ] Verification popups for delete actions +- [ ] Allow user X to insert expense of user Y - make user Y have to approve it ### Stack @@ -59,5 +73,6 @@ used ## Thanks to -https://threedots.tech/post/database-transactions-in-go/ -https://github.com/m110 +This excellent write up: +- [Database Transactions in GO](https://threedots.tech/post/database-transactions-in-go/), +by [m110](https://github.com/m110) diff --git a/src/api/login.go b/src/api/login.go index 17b89f9..03789b6 100644 --- a/src/api/login.go +++ b/src/api/login.go @@ -4,7 +4,6 @@ import ( exp "expenses/expenses" "expenses/expenses/auth" "github.com/gin-gonic/gin" - "log" "net/http" ) @@ -21,19 +20,14 @@ func login(c *gin.Context) { return } - log.Println("user:", loginData.Name) - log.Println("pass:", loginData.Pass) - user, err := exp.App.ValidateCredentials(loginData.Name, loginData.Pass) if err != nil { - log.Println("Error validating user: ", err) // TODO - go to an error page or login failed or something return } token, err := auth.GenerateToken(user.UserName) if err != nil { - log.Println("Error generating token: ", err) // TODO - get error return return } diff --git a/src/expenses/auth/authMiddlware.go b/src/expenses/auth/authMiddlware.go index 7787a13..41453d0 100644 --- a/src/expenses/auth/authMiddlware.go +++ b/src/expenses/auth/authMiddlware.go @@ -14,18 +14,14 @@ import ( func AuthMiddleware() gin.HandlerFunc { log.Println("Are we authing?") return func(c *gin.Context) { - log.Println("Returning the auth middleware function") var user *mod.User var err error // Check if we have a cookie for the session session := sessions.Default(c) uid := session.Get("user_id") - log.Println("UID is: ", uid) if uid != nil { - log.Println("Got UUID: ", uid) user, err = exp.App.GetUser(uid.(int32)) - log.Println("Got User: ", user) if err != nil { // TODO - what do we return here? return @@ -33,14 +29,12 @@ func AuthMiddleware() gin.HandlerFunc { } if user == nil { - log.Println("No User: ", user) c.Redirect(http.StatusTemporaryRedirect, "/login") // Just to be sure I recon c.Abort() return } - log.Println("Setting User: ", user) c.Set("user", user) c.Next() }