1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Passwords stored as hashes instead of on the server

This commit is contained in:
Zack Scholl
2016-09-10 07:45:36 -04:00
parent 87e5439854
commit ccfe66e973
3 changed files with 21 additions and 3 deletions

View File

@@ -149,7 +149,8 @@ func encryptionRoute(c *gin.Context) {
if err != nil {
panic(err)
}
p.Locked = jsonLoad.Password
hashedPassword, _ := HashPassword([]byte(jsonLoad.Password))
p.Locked = string(hashedPassword)
p.save(p.CurrentText)
c.JSON(200, gin.H{
"status": "posted",
@@ -173,7 +174,9 @@ func encryptionRoute(c *gin.Context) {
if err != nil {
panic(err)
}
if len(p.Locked) > 0 && p.Locked == jsonLoad.Password {
if len(p.Locked) > 0 &&
(p.Locked == jsonLoad.Password ||
CheckPasswordHash([]byte(p.Locked), []byte(jsonLoad.Password)) == nil) {
p.Locked = ""
p.save(p.CurrentText)
c.JSON(200, gin.H{