forked from Druadach/Valine-Admin
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: try to merge anti spam * feat: router of sign up * feat: check spam
- Loading branch information
Showing
13 changed files
with
388 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Launch Program", | ||
"skipFiles": [ | ||
"<node_internals>/**" | ||
], | ||
"program": "${workspaceFolder}/server.js" | ||
} | ||
] | ||
} |
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
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,50 @@ | ||
'use strict' | ||
const process = require('node:process') | ||
const router = require('express').Router() | ||
const AV = require('leanengine') | ||
|
||
const User = AV.Object.extend('_User') | ||
|
||
// Comment 列表 | ||
router.get('/', (req, res) => { | ||
if (req.currentUser) { | ||
res.redirect('/comments') | ||
} | ||
else { | ||
const adminMail = process.env.BLOGGER_EMAIL || process.env.SMTP_USER | ||
const q = new AV.Query(User) | ||
q.equalTo('email', adminMail) | ||
q.find().then((results) => { | ||
if (results.length > 0) { | ||
res.redirect('/') | ||
} | ||
else { | ||
res.render('sign-up', { | ||
email: adminMail, | ||
}) | ||
} | ||
}) | ||
} | ||
}) | ||
|
||
router.post('/', (req, res) => { | ||
const adminMail = process.env.BLOGGER_EMAIL || process.env.SMTP_USER | ||
const q = new AV.Query(User) | ||
q.equalTo('email', adminMail) | ||
q.find().then((results) => { | ||
if (results.length > 0) { | ||
res.redirect('/') | ||
} | ||
else { | ||
const user = new AV.User() | ||
user.setUsername(req.body.username) | ||
user.setPassword(req.body.password) | ||
user.setEmail(req.body.email) | ||
user.signUp().then(() => { | ||
}) | ||
res.redirect('/') | ||
} | ||
}) | ||
}) | ||
|
||
module.exports = router |
Oops, something went wrong.