Validator handles validation of user's credentials, like email or phone.
| 15 | |
| 16 | // Validator handles validation of user's credentials, like email or phone. |
| 17 | type 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 | |
| 61 | func ValidateHostURL(origUrl string) (string, error) { |
| 62 | hostUrl, err := url.Parse(origUrl) |
no outgoing calls
no test coverage detected
searching dependent graphs…