Skip to content

Commit

Permalink
Merge pull request enBloc-org#311 from enBloc-org/enBloc-org#251/emai…
Browse files Browse the repository at this point in the history
…l-templates

enBloc-org#251/email templates
  • Loading branch information
camelPhonso authored Aug 1, 2024
2 parents 555c8f8 + 112babf commit 1cabee6
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 127 deletions.
2 changes: 0 additions & 2 deletions app/(auth)/signup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import AuthForm from '@/components/AuthForm';
import insertRow from '@/supabase/models/insertRow';
import newServerClient from '@/supabase/utils/newServerClient';
import { PartialProfile } from '@/types/supabaseTypes';
import { headers } from 'next/headers';
import { redirect } from 'next/navigation';

export default function SignUp({
Expand All @@ -18,7 +17,6 @@ export default function SignUp({
const { data, error } = await supabase.auth.signUp({
email: formData.get('email') as string,
password: formData.get('password') as string,
options: { emailRedirectTo: `${headers().get('origin')}/login` },
});

if (error) {
Expand Down
1 change: 1 addition & 0 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = defineConfig({
viewportWidth: 1920,
viewportHeight: 1080,
baseUrl: 'http://localhost:3000',
experimentalSessionAndOrigin: true,
env: {
loginEmail: '[email protected]',
loginPassword: 'schemu8s',
Expand Down
41 changes: 41 additions & 0 deletions cypress/e2e/authorisation.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,45 @@ describe('Authorisation Spec', () => {
.contains(/user already registered/gi)
.should('be.visible');
});

it('User should be able to signup with a new email address', () => {
cy.visit('https://www.guerrillamail.com');
cy.get('#email-widget')
.invoke('text')
.then((randomEmail) => {
cy.origin(
'http://localhost:3000/',
{ args: randomEmail },
(randomEmail) => {
cy.visit('/signup');
cy.get('input[name="user_name"]').type('existing user');
cy.get('input[name="email"]').type(randomEmail);
cy.get('input[id="password"]').type('NewPasswo0rd!');
cy.get('input[id="confirmPassword"]').type('NewPasswo0rd!');
cy.get('input[id="agreeCheckbox"]').check();
cy.get('button')
.contains(/register/gi)
.click();
}
);
cy.origin(
'http://127.0.0.1:54324',
{ args: randomEmail },
(randomEmail) => {
cy.visit('/');
cy.get('input[placeholder="mailbox"]')
.type(randomEmail)
.closest('form')
.submit();
cy.get('div .message-list-entry').click();
cy.get('a')
.contains(/confirm email/gi)
.invoke('attr', 'href')
.then((linkAddress) => {
expect(linkAddress).to.include('/login');
});
}
);
});
});
});
240 changes: 120 additions & 120 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 8 additions & 5 deletions supabase/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ enabled = true
# in emails.
site_url = "http://127.0.0.1:3000"
# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.
additional_redirect_urls = ["https://127.0.0.1:3000"]
additional_redirect_urls = ["https://127.0.0.1:3000/**"]
# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week).
jwt_expiry = 3600
# If disabled, the refresh token will never expire.
Expand All @@ -98,14 +98,17 @@ enable_signup = true
# addresses. If disabled, only the new email is required to confirm.
double_confirm_changes = true
# If enabled, users need to confirm their email address before signing in.
enable_confirmations = false
enable_confirmations = true
# Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email.
max_frequency = "1s"

# Uncomment to customize email template
# [auth.email.template.invite]
# subject = "You have been invited"
# content_path = "./supabase/templates/invite.html"
[auth.email.template.confirmation]
subject = "Welcome to Kindly."
content_path = "./supabase/templates/confirmation.html"
[auth.email.template.recovery]
subject = "Password reset"
content_path = "./supabase/templates/recovery.html"

[auth.sms]
# Allow/disallow new user signups via SMS to your project.
Expand Down
Loading

0 comments on commit 1cabee6

Please sign in to comment.