72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { singleton } from 'zutils'
|
|
import { NetClient } from 'net/NetClient'
|
|
|
|
export const DEFAULT_VERIFY_HTML = `
|
|
<h1>Email Verification</h1>
|
|
<p>CEBG needs to confirm your email address is still valid. Please click the link below to confirm you received this mail.</p>
|
|
<p><a href="{{href}}" target="_blank">Verify Email</a></p>
|
|
<p>If you're worried about this email being legitimate, you can visit CEBG directly to confirm your email needs verifying. After doing so, please don't forget to click the link above.</p>
|
|
`
|
|
|
|
export const DEFAULT_REGIST_SUBJECT = 'CEBG regist code'
|
|
export const DEFAULT_REGIST_HTML = `
|
|
<h1>Your CEBG regist code is</h1>
|
|
<h1>{{ocde}}</h1>
|
|
<p>{{time}}</p>
|
|
<p>This is your one time code that expires in 5 minutes.</p>
|
|
<p>Use it to login CEBG. Never share this code with anyone.</p>
|
|
`
|
|
|
|
export const DEFAULT_RESET_SUBJECT = 'CEBG reset password code'
|
|
export const DEFAULT_RESET_HTML = `
|
|
<h1>Your CEBG reset password code is</h1>
|
|
<h1>{{ocde}}</h1>
|
|
<p>{{time}}</p>
|
|
<p>This is your one time code that expires in 5 minutes.</p>
|
|
<p>Use it to login CEBG. Never share this code with anyone.</p>
|
|
`
|
|
export const DEFAULT_VERIFY_MAIL_SUBJECT = 'CEBG verify email code'
|
|
export const DEFAULT_VERIFY_MAIL_HTML = `
|
|
<h1>Your CEBG verify email code is</h1>
|
|
<h1>{{ocde}}</h1>
|
|
<p>{{time}}</p>
|
|
<p>This is your one time code that expires in 5 minutes.</p>
|
|
<p>Use it to login CEBG. Never share this code with anyone.</p>
|
|
`
|
|
|
|
export const DEFAULT_LOGIN_MAIL_SUBJECT = 'Counter Fire email login code'
|
|
export const DEFAULT_LOGIN_MAIL_HTML = `
|
|
<h1>Your Counter Fire email login code is</h1>
|
|
<h1>{{ocde}}</h1>
|
|
<p>{{time}}</p>
|
|
<p>This is your one time code that expires in 5 minutes.</p>
|
|
<p>Use it to login Counter Fire. Never share this code with anyone.</p>
|
|
`
|
|
|
|
export interface IMailData {
|
|
from?: string
|
|
to: string
|
|
subject?: string
|
|
text?: string
|
|
html?: string
|
|
}
|
|
|
|
const DEFAULT_MSG_DATA: IMailData = {
|
|
from: 'CEBG <noreply@cebg.games>',
|
|
to: '',
|
|
subject: 'Please verify your email address',
|
|
}
|
|
const MAIL_SVR = process.env.EMAIL_SERVER
|
|
|
|
@singleton
|
|
export class EmailSvr {
|
|
public sendMail(msg: IMailData) {
|
|
Object(DEFAULT_MSG_DATA).zssign(msg)
|
|
let reqData = {
|
|
url: MAIL_SVR + '/mail/send',
|
|
data: JSON.stringify({ message: msg }),
|
|
}
|
|
return new NetClient().httpPost(reqData)
|
|
}
|
|
}
|