You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible or can you make it possible that registration is only allowed for users with certain email addresses (domains)?
It is useful to restrict registration so that not everyone can use the service. However, within an organization everyone should be able to create a user account and use the service.
The text was updated successfully, but these errors were encountered:
Pretty simple but you'll have make slight edits to the code. I did it for my org and works like a charm.
Open .env file, add this line somewhere: #add a domain var here to limit so don't have to make changes to code when it needs to be modified. LIMIT_EMAIL_DOMAIN=youremaildomain.com
In client/const/site-theme.ts add: export const LIMIT_EMAIL_DOMAIN = publicRuntimeConfig.LIMIT_EMAIL_DOMAIN; //get var from .env file
in client/pages/login.tsx:
import { LIMIT_EMAIL_DOMAIN } from "../consts/site-theme";
...
function onSubmit(type: "login" | "signup") {
return async e => {
....
const { email, password } = formState.values;
const emailRegex = LIMIT_EMAIL_DOMAIN != "" ? new RegExp("^[A-Za-z][A-Za-z0-9._%+-]+@" + LIMIT_EMAIL_DOMAIN + "$", "g") : null;
...
if (!email) {
return setError("Email address must not be empty.");
}
if (LIMIT_EMAIL_DOMAIN != "" && !emailRegex.test(email)) { //if domain exists and doesn't match the regex then error out
return setError("Cannot use the provided email address.");
}
...
npm run build
This only works for one domain, but you can always code it to make it comma separated, etc.. for multiple domains.
Is it possible or can you make it possible that registration is only allowed for users with certain email addresses (domains)?
It is useful to restrict registration so that not everyone can use the service. However, within an organization everyone should be able to create a user account and use the service.
The text was updated successfully, but these errors were encountered: