General Instructions on how to run the code:
-
/signupallows user to register new user into the database
/loginauthenticate users and generate jwt token for logging in
/homeonly authenticated users can view this page
/logoutlogs user out by deleting the existing cookie
/balanceallows user to check his/her wallet balance
/awardadds coin to the recipient's account
/transfertransfer coins from logged in user to the recipient's account
- Open project folder in terminal and build the package by
go build - Run the
.\iitk-coin.exefile. Server will start atlocalhost:8080 - Open POSTMAN or INSOMNIA and
POSTrequest athttp://localhost:8080/signup - Input the data in JSON format, for example:\
{
"rollno":"190103",
"fullname":"Aman Dixit",
"password":"dxaman"
}
- If the Roll Number already exist, it will not register a duplicate entry.
- If Roll Number does not exist then it will create a new entry and register the user. Password will be stored after salting and hashing.
- Proceed to login by sending
POSTrequest athttp://localhost:8080/loginand input the data in JSON format, for example:\
{
"rollno":"190103",
"password":"dxaman"
}
- If successfully logged in,
http://localhost:8080/homepage will be accessible and returnHello, 190103. - To logout of the system just send empty
POSTrequest athttp://localhost:8080/logout - To check your current wallet balance, send
GETrequest athttp://localhost:8080/balance - To award a user with some coins, send
POSTrequest athttp://localhost:8080/awardand input the data in JSON format, for example:\
{
"to":"190558",
"coins":50
}
- To transfer coinsfrom your account to a user, send
POSTrequest athttp://localhost:8080/transferand input the data in JSON format, for example:\
{
"to":"190558",
"coins":50
}
index.gocontains the funcmainand call all the endpoints.handlers.godefines functions of all endpoints and responsible for generating and managingtokensandcookies.validation.gochecks for already existing users in database and matches password with the existing entries in the database.hashing.gois responsible for converting simple password into salted and hashed password usingbcrypt.transactions.goconsists of functions responsible for transaction related endpoints.data_dxaman_0.dbcontains all the information of registered user in a form of table.