Skip to content
This repository has been archived by the owner on Jan 6, 2024. It is now read-only.

Commit

Permalink
Fix reCAPTCHA
Browse files Browse the repository at this point in the history
  • Loading branch information
MrXyfir committed Mar 5, 2019
1 parent c54a437 commit 89c37ef
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The goal of Accownt is to be a full-featured, standalone account system that's s
- Easy integration into new and existing applications of any stack
- CAPTCHA support
- Optional, just set your reCAPTCHA key
- Thanks to [reCAPTCHA](https://www.google.com/recaptcha/)
- Thanks to [reCAPTCHA v2](https://www.google.com/recaptcha/)
- JSON Web Tokens (JWT)
- Shared JWT and cookie between Accownt and your app for session authentication
- Thanks to [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken)
Expand Down
7 changes: 5 additions & 2 deletions server/lib/register/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { sendMail } from 'lib/email/send';
import * as storage from 'node-persist';
import { Accownt } from 'types/accownt';
import { signJWT } from 'lib/jwt/sign';
import * as qs from 'qs';
import axios from 'axios';

const {
Expand All @@ -24,7 +25,7 @@ export async function startRegistration(
if (RECAPTCHA_KEY) {
const captcha = await axios.post(
'https://www.google.com/recaptcha/api/siteverify',
{ secret: RECAPTCHA_KEY, response: recaptcha }
qs.stringify({ secret: RECAPTCHA_KEY, response: recaptcha })
);
if (!captcha.data.success) throw 'Invalid captcha';
}
Expand Down Expand Up @@ -52,9 +53,11 @@ export async function startRegistration(

// Send verification email
const token = await signJWT(user.id, email, TEMP_JWT_EXPIRES_IN);
const link = `${ACCOWNT_API_URL}/register?jwt=${token}`;
await sendMail({
subject: `${NAME} Email Verification`,
text: `${ACCOWNT_API_URL}/register?jwt=${token}`,
html: `<a href="${link}">Verify my email.</a>`,
text: link,
to: email
});

Expand Down
30 changes: 27 additions & 3 deletions server/package-lock.json

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

2 changes: 2 additions & 0 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"node-persist": "^3.0.4",
"nodemailer": "^5.1.1",
"qrcode": "^1.3.3",
"qs": "^6.6.0",
"speakeasy": "^2.0.0"
},
"devDependencies": {
Expand All @@ -42,6 +43,7 @@
"@types/node-persist": "0.0.33",
"@types/nodemailer": "^4.6.6",
"@types/qrcode": "^1.3.1",
"@types/qs": "^6.5.2",
"@types/speakeasy": "^2.0.4",
"jest": "^24.1.0",
"jest-extended": "^0.11.1",
Expand Down

0 comments on commit 89c37ef

Please sign in to comment.