File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed
Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,29 @@ public function __construct(StoreInterface $store, string $redirectUri)
4242 $ this ->clientId = self ::getOrigin ($ this ->redirectUri );
4343 }
4444
45+ /**
46+ * Normalize one or more email addresses.
47+ *
48+ * This method is useful when comparing user input to an email address
49+ * returned in a Portier token. It is not necessary to call this before
50+ * `authenticate`, normalization is already part of the authentication
51+ * process.
52+ *
53+ * This is currently implemented by making an HTTP call to Portier, without
54+ * cache.
55+ *
56+ * @param string[] $emails Email addresses to normalize.
57+ * @return string[] Normalized email addresses, empty strings for invalid.
58+ */
59+ public function normalize (array $ emails ): array
60+ {
61+ $ res = $ this ->store ->guzzle ->post (
62+ $ this ->broker . '/normalize ' ,
63+ ['body ' => implode ("\n" , $ emails )]
64+ );
65+ return explode ("\n" , (string ) $ res ->getBody ());
66+ }
67+
4568 /**
4669 * Start authentication of an email address.
4770 * @param string $email Email address to authenticate.
You can’t perform that action at this time.
0 commit comments