-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
689e3e9
commit 7fa70e3
Showing
21 changed files
with
2,049 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { BaseMailer, MessageContract } from '@ioc:Adonis/Addons/Mail' | ||
import View from '@ioc:Adonis/Core/View' | ||
|
||
export default class VerifyEmail extends BaseMailer { | ||
constructor(private email: string, private signedUrl: string) { | ||
super() | ||
} | ||
|
||
public async prepare(message: MessageContract) { | ||
const html = await View.render('emails/verify-email', { signedUrl: this.signedUrl }) | ||
|
||
message | ||
.subject('Valide ton vote - Le Classement des Associations ✨') | ||
.from('no-reply@le-classement.fr') | ||
.to(this.email) | ||
.html(html) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { BaseModel, BelongsTo, belongsTo, column } from '@ioc:Adonis/Lucid/Orm' | ||
import { DateTime } from 'luxon' | ||
import Association from './Association' | ||
|
||
export default class Vote extends BaseModel { | ||
@column({ isPrimary: true }) | ||
public id: number | ||
|
||
@column() | ||
public associationId: number | ||
|
||
@column() | ||
public email: string | ||
|
||
@column() | ||
public acceptClassement: boolean | ||
|
||
@column() | ||
public acceptActivities: boolean | ||
|
||
@column.dateTime({ autoCreate: true }) | ||
public createdAt: DateTime | ||
|
||
@column.dateTime({ autoCreate: true, autoUpdate: true }) | ||
public updatedAt: DateTime | ||
|
||
@belongsTo(() => Association) | ||
public association: BelongsTo<typeof Association> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { schema, rules, CustomMessages } from '@ioc:Adonis/Core/Validator' | ||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext' | ||
|
||
export default class VoteStoreValidator { | ||
constructor(protected ctx: HttpContextContract) {} | ||
|
||
public schema = schema.create({ | ||
email: schema.string([ | ||
rules.trim(), | ||
rules.maxLength(255), | ||
rules.email(), | ||
rules.normalizeEmail({ | ||
allLowercase: true, | ||
gmailRemoveDots: true, | ||
gmailRemoveSubaddress: true, | ||
icloudRemoveSubaddress: true, | ||
outlookdotcomRemoveSubaddress: true, | ||
yahooRemoveSubaddress: true, | ||
}), | ||
rules.unique({ | ||
table: 'votes', | ||
column: 'email', | ||
}), | ||
]), | ||
acceptClassement: schema.boolean.optional(), | ||
acceptActivities: schema.boolean.optional(), | ||
}) | ||
|
||
public messages: CustomMessages = { | ||
'association_id.exists': "Cette association n'existe pas", | ||
'email.required': 'Un email est requis', | ||
'email.maxLength': "L'email ne doit pas dépasser 255 caractères", | ||
'email.email': "Cet email n'est pas valide", | ||
'email.unique': 'Cet email est déjà utilisé', | ||
'accept_classement.boolean': 'Cette option doit être un booléen', | ||
'accept_activities.boolean': 'Cette option doit être un booléen', | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* Config source: https://git.io/JvgAf | ||
* | ||
* Feel free to let us know via PR, if you find something broken in this contract | ||
* file. | ||
*/ | ||
|
||
import Env from '@ioc:Adonis/Core/Env' | ||
import { mailConfig } from '@adonisjs/mail/build/config' | ||
|
||
export default mailConfig({ | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Default mailer | ||
|-------------------------------------------------------------------------- | ||
| | ||
| The following mailer will be used to send emails, when you don't specify | ||
| a mailer | ||
| | ||
*/ | ||
mailer: 'smtp', | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| Mailers | ||
|-------------------------------------------------------------------------- | ||
| | ||
| You can define or more mailers to send emails from your application. A | ||
| single `driver` can be used to define multiple mailers with different | ||
| config. | ||
| | ||
| For example: Postmark driver can be used to have different mailers for | ||
| sending transactional and promotional emails | ||
| | ||
*/ | ||
mailers: { | ||
/* | ||
|-------------------------------------------------------------------------- | ||
| Smtp | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Uses SMTP protocol for sending email | ||
| | ||
*/ | ||
smtp: { | ||
driver: 'smtp', | ||
host: Env.get('SMTP_HOST'), | ||
port: Env.get('SMTP_PORT'), | ||
auth: { | ||
user: Env.get('SMTP_USERNAME'), | ||
pass: Env.get('SMTP_PASSWORD'), | ||
type: 'login', | ||
}, | ||
}, | ||
|
||
/* | ||
|-------------------------------------------------------------------------- | ||
| SES | ||
|-------------------------------------------------------------------------- | ||
| | ||
| Uses Amazon SES for sending emails. You will have to install the aws-sdk | ||
| when using this driver. | ||
| | ||
| ``` | ||
| npm i aws-sdk | ||
| ``` | ||
| | ||
*/ | ||
ses: { | ||
driver: 'ses', | ||
apiVersion: '2010-12-01', | ||
key: Env.get('SES_ACCESS_KEY'), | ||
secret: Env.get('SES_ACCESS_SECRET'), | ||
region: Env.get('SES_REGION'), | ||
sslEnabled: true, | ||
sendingRate: 10, | ||
maxConnections: 5, | ||
}, | ||
}, | ||
}) |
Oops, something went wrong.