mirror of
https://github.com/Unkn0wnCat/matrix-veles.git
synced 2025-07-31 23:28:48 +02:00
Create auth API & comment code
This commit is contained in:
parent
1b15b12859
commit
c8d1c33cb4
17 changed files with 475 additions and 101 deletions
|
@ -2,14 +2,20 @@ package model
|
|||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
)
|
||||
|
||||
type DBUser struct {
|
||||
Username string `bson:"username" json:"username"`
|
||||
HashedPassword string `bson:"password" json:"password"`
|
||||
ID primitive.ObjectID `bson:"_id" json:"id"`
|
||||
|
||||
Password *string `bson:"-" json:"-"`
|
||||
Username string `bson:"username" json:"username"` // Username is the username the user has
|
||||
HashedPassword string `bson:"password" json:"password"` // HashedPassword contains the bcrypt-ed password
|
||||
|
||||
MatrixLinks []*string `bson:"matrix_links" json:"matrix_links"` // MatrixLinks is the matrix-users this user has verified ownership over
|
||||
PendingMatrixLinks []*string `bson:"pending_matrix_links" json:"pending_matrix_links"` // PendingMatrixLinks is the matrix-users pending verification
|
||||
|
||||
Password *string `bson:"-" json:"-"` // Password may never be sent out!
|
||||
}
|
||||
|
||||
func (usr *DBUser) HashPassword() error {
|
||||
|
@ -23,6 +29,7 @@ func (usr *DBUser) HashPassword() error {
|
|||
}
|
||||
|
||||
usr.HashedPassword = base64.StdEncoding.EncodeToString(hash)
|
||||
usr.Password = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue