MCPcopy Create free account
hub / github.com/daodst/chat / QueryAccountByPassword

Method QueryAccountByPassword

userapi/internal/api.go:854–866  ·  view source on GitHub ↗
(ctx context.Context, req *api.QueryAccountByPasswordRequest, res *api.QueryAccountByPasswordResponse)

Source from the content-addressed store, hash-verified

852}
853
854func (a *UserInternalAPI) QueryAccountByPassword(ctx context.Context, req *api.QueryAccountByPasswordRequest, res *api.QueryAccountByPasswordResponse) error {
855 acc, err := a.DB.GetAccountByPassword(ctx, req.Localpart, req.PlaintextPassword)
856 switch err {
857 case sql.ErrNoRows: // user does not exist
858 return nil
859 case bcrypt.ErrMismatchedHashAndPassword: // user exists, but password doesn't match
860 return nil
861 default:
862 res.Exists = true
863 res.Account = acc
864 return nil
865 }
866}
867
868func (a *UserInternalAPI) SetDisplayName(ctx context.Context, req *api.PerformUpdateDisplayNameRequest, _ *struct{}) error {
869 return a.DB.SetDisplayName(ctx, req.Localpart, req.DisplayName)

Callers

nothing calls this directly

Calls 1

GetAccountByPasswordMethod · 0.80

Tested by

no test coverage detected