Using Gin frame work and Postgress database testing Simple web application written in golang using postgres database
Package used for this WebApp
GORM
| https://gorm.io/
| For Database opration
GIN
| https://gin-gonic.com/
| For HTTP web framework
CRYPTO
| https://pkg.go.dev/golang.org/x/crypto@v0.8.0
| Password encryption and decryption
JWT
| https://pkg.go.dev/github.com/golang-jwt/jwt
| For implementation of JSON Web Tokens.
GODOTENV
| https://github.com/joho/godotenv
| For loads env vars from a .env file
Token for JWT Authentication and also using if the user or admin is alredy logged or not through this
-
User token is saved as USERTOKEN
-
Admin token is seved as ADMINTOKEN
LogIn
SignUp
Edit Profile
User Profile Viewer
LogIn
SignUp
Add Admi
List All User
Edit User
Delete User
1. Run your server eg: local server with postgres database
2. Give the database details to .env file
3. go run main.go
* Use this route for working eg: localhost://8080/login
Admin route
POST /adminlogin
POST /addadmin
GET /userview
GET /deleteuser
PUT /edituser
User route
POST /signup
POST /login
GET /userprofile
PUT /useredit
-
customize with your detail
user = "your postgres username" password = "password of your postgres user" database = "your server name" localhost = "your host"
PORT = 8080 DATABASE = "host=localhost user="user" password="password" dbname="database" port="port" sslmode=disable"
// User key // You can edit the key
SCRECTKEY = AHDBHSIHSNNSGHSHSJHJ
ADMINKEY = KAHNDKJDHBMKJSNND
- Receive Name, email , password from request
- Check if user is already registered. (Check with email)
- If user if not present, hash the password
- Create new user in the db with email and hashed password
- Send success response back
- Recieve email and password from request
- Find user info from database
- If user is not found (user.ID == 0), return invalid username or password response
- Compare password from request and database
- If password is incorrect, return invalid username or password response
- If password is correct, create token, set in in cookie
- Recieve the id from request
- check the id if exist or not
- find the user from database
- delete and update the database
- send sucess responce
- Collect the user information
- Check the use id exist or not
- Find the user from databse
- Update the user information
- Update the database
- Sent responce
Upcomming Function
- Admin can block user -- > Comming soon..!!
- When Admin Delete user only update database Delete_status value
- User can delete Profile
- When user delete profile only update database Delete_Status value | Auth Using
- Google Signup
- Twitter signup
- Facebook signup
Upcomming Functionality
- Template Loading and Front End Design