diff --git a/core/mysql.go b/core/mysql.go index e001c19f..65c0b2e7 100644 --- a/core/mysql.go +++ b/core/mysql.go @@ -30,15 +30,15 @@ type Mysql struct { // User 用户表记录结构体 type User struct { - ID uint - Username string - Password string - OriginPass string - Quota int64 - Download uint64 - Upload uint64 - UseDays uint - ExpiryDate string + ID uint + Username string + Password string + EncryptPass string + Quota int64 + Download uint64 + Upload uint64 + UseDays uint + ExpiryDate string } // PageQuery 分页查询的结构体 @@ -90,15 +90,15 @@ func (mysql *Mysql) CreateTable() { func queryUserList(db *sql.DB, sql string) ([]*User, error) { var ( - username string - originPass string - passShow string - download uint64 - upload uint64 - quota int64 - id uint - useDays uint - expiryDate string + username string + encryptPass string + passShow string + download uint64 + upload uint64 + quota int64 + id uint + useDays uint + expiryDate string ) var userList []*User rows, err := db.Query(sql) @@ -107,19 +107,19 @@ func queryUserList(db *sql.DB, sql string) ([]*User, error) { } defer rows.Close() for rows.Next() { - if err := rows.Scan(&id, &username, &originPass, &passShow, "a, &download, &upload, &useDays, &expiryDate); err != nil { + if err := rows.Scan(&id, &username, &encryptPass, &passShow, "a, &download, &upload, &useDays, &expiryDate); err != nil { return nil, err } userList = append(userList, &User{ - ID: id, - Username: username, - Password: passShow, - OriginPass: originPass, - Download: download, - Upload: upload, - Quota: quota, - UseDays: useDays, - ExpiryDate: expiryDate, + ID: id, + Username: username, + Password: passShow, + EncryptPass: encryptPass, + Download: download, + Upload: upload, + Quota: quota, + UseDays: useDays, + ExpiryDate: expiryDate, }) } return userList, nil @@ -127,21 +127,21 @@ func queryUserList(db *sql.DB, sql string) ([]*User, error) { func queryUser(db *sql.DB, sql string) (*User, error) { var ( - username string - originPass string - passShow string - download uint64 - upload uint64 - quota int64 - id uint - useDays uint - expiryDate string + username string + encryptPass string + passShow string + download uint64 + upload uint64 + quota int64 + id uint + useDays uint + expiryDate string ) row := db.QueryRow(sql) - if err := row.Scan(&id, &username, &originPass, &passShow, "a, &download, &upload, &useDays, &expiryDate); err != nil { + if err := row.Scan(&id, &username, &encryptPass, &passShow, "a, &download, &upload, &useDays, &expiryDate); err != nil { return nil, err } - return &User{ID: id, Username: username, Password: passShow, OriginPass: originPass, Download: download, Upload: upload, Quota: quota, UseDays: useDays, ExpiryDate: expiryDate}, nil + return &User{ID: id, Username: username, Password: passShow, EncryptPass: encryptPass, Download: download, Upload: upload, Quota: quota, UseDays: useDays, ExpiryDate: expiryDate}, nil } // CreateUser 创建Trojan用户 diff --git a/core/tools.go b/core/tools.go index 3382c556..1a0f0de6 100644 --- a/core/tools.go +++ b/core/tools.go @@ -76,7 +76,7 @@ func (mysql *Mysql) DumpSql(filePath string) error { for _, user := range userList { writer.WriteString(fmt.Sprintf(` INSERT INTO users(id, username, password, passwordShow, quota, download, upload, useDays, expiryDate) VALUES (%d, '%s','%s','%s', %d, %d, %d, %d, '%s');`, - user.ID, user.Username, user.OriginPass, user.Password, user.Quota, user.Download, user.Upload, user.UseDays, user.ExpiryDate)) + user.ID, user.Username, user.EncryptPass, user.Password, user.Quota, user.Download, user.Upload, user.UseDays, user.ExpiryDate)) } writer.WriteString("\n") writer.Flush() diff --git a/web/auth.go b/web/auth.go index b7022fe4..f21bf14a 100644 --- a/web/auth.go +++ b/web/auth.go @@ -62,7 +62,7 @@ func init() { if user == nil { return nil, jwt.ErrFailedAuthentication } - password = user.Password + password = user.EncryptPass } else { if password, err = core.GetValue(userID + "_pass"); err != nil { return nil, err