Open mamo2021 opened 1 year ago
Not right now, you can temporarily enable signup, allow some users to sign up and then disable the signup option again.
Pretty simple but you'll have make slight edits to the code. I did it for my org and works like a charm.
1) Open .env file, add this line somewhere: `
LIMIT_EMAIL_DOMAIN=youremaildomain.com `
2) In client/const/site-theme.ts add:
export const LIMIT_EMAIL_DOMAIN = publicRuntimeConfig.LIMIT_EMAIL_DOMAIN; //get var from .env file
3) 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.");
}
...
4)
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.