MCPcopy Index your code
hub / github.com/tinode/chat / Validator

Interface Validator

server/validate/validator.go:17–59  ·  view source on GitHub ↗

Validator handles validation of user's credentials, like email or phone.

Source from the content-addressed store, hash-verified

15
16// Validator handles validation of user's credentials, like email or phone.
17type Validator interface {
18 // Init initializes the validator.
19 Init(jsonconf string) error
20
21 // IsInitialized returns true if the validator is initialized.
22 IsInitialized() bool
23
24 // PreCheck pre-validates the credential without sending an actual request for validation:
25 // check uniqueness (if appropriate), format, etc
26 // Returns normalized credential prefixed with an appropriate namespace prefix.
27 PreCheck(cred string, params map[string]any) (string, error)
28
29 // Request sends a request for validation to the user. Returns true if it's a new credential,
30 // false if it re-sent request for an existing unconfirmed credential.
31 // user: UID of the user making the request.
32 // cred: credential being validated, such as email or phone.
33 // lang: user's human language as repored in the session.
34 // resp: optional response if user already has it (i.e. captcha/recaptcha).
35 // tmpToken: temporary authentication token to include in the request.
36 Request(user t.Uid, cred, lang, resp string, tmpToken []byte) (bool, error)
37
38 // ResetSecret sends a message with instructions for resetting an authentication secret.
39 // cred: address to use for the message.
40 // scheme: authentication scheme being reset.
41 // lang: human language as reported in the session.
42 // tmpToken: temporary authentication token
43 // params: authentication params.
44 ResetSecret(cred, scheme, lang string, tmpToken []byte, params map[string]any) error
45
46 // Check checks validity of user's response.
47 // Returns the value of validated credential on success.
48 Check(user t.Uid, resp string) (string, error)
49
50 // Remove deletes or deactivates user's given value.
51 Remove(user t.Uid, value string) error
52
53 // Delete deletes user's record.
54 Delete(user t.Uid) error
55
56 // TempAuthScheme returns a temporary authentication method used by this validator.
57 // It should be either "code" or "token".
58 TempAuthScheme() (string, error)
59}
60
61func ValidateHostURL(origUrl string) (string, error) {
62 hostUrl, err := url.Parse(origUrl)

Callers 12

rewriteTagFunction · 0.65
replyCreateUserFunction · 0.65
addCredsFunction · 0.65
authSecretResetMethod · 0.65
validatedCredsFunction · 0.65
NewSessionMethod · 0.65
DeleteMethod · 0.65
EvictUserMethod · 0.65
deleteCredFunction · 0.65
UploadMethod · 0.65
DeleteMethod · 0.65
authSecretResetMethod · 0.65

Implementers 2

validatorserver/validate/email/validate.go
validatorserver/validate/tel/validate.go

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…