mirror of
https://github.com/Akif9748/akf-forum.git
synced 2024-11-26 05:10:41 +03:00
added gravatar support
This commit is contained in:
parent
250b525e5a
commit
7f655de129
6 changed files with 17 additions and 9 deletions
|
@ -55,13 +55,14 @@ Akf-forum has got an API for AJAX (fetch), other clients etc. And, you can learn
|
||||||
- delete admin???
|
- delete admin???
|
||||||
- change category name
|
- change category name
|
||||||
- _id
|
- _id
|
||||||
- ADD gavatar support
|
- add support for transition aroun gravatar
|
||||||
|
|
||||||
|
### theme to do:
|
||||||
|
- theme change
|
||||||
- routes/api/routes/users.js check,
|
- routes/api/routes/users.js check,
|
||||||
themes/default/extra/footer.ejs check,
|
themes/default/extra/footer.ejs check,
|
||||||
themes/default/extra/meta.ejs check
|
themes/default/extra/meta.ejs check
|
||||||
- "defaultThreadState" ??? better case
|
- add theme support again, but only works with css folder. Put every css file into one file. (themes/default/css/main.css)
|
||||||
|
|
||||||
|
|
||||||
### front-end
|
### front-end
|
||||||
- better usermenu for user profile
|
- better usermenu for user profile
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
"windowMs": 60000
|
"windowMs": 60000
|
||||||
},
|
},
|
||||||
"discord_auth": "",
|
"discord_auth": "",
|
||||||
"defaultThreadState": "OPEN",
|
"default_thread_state": "OPEN",
|
||||||
"email_auth": false,
|
"email_auth": false,
|
||||||
"default_user_state": "ACTIVE",
|
"default_user_state": "ACTIVE",
|
||||||
"host": "https://akf-forum.glitch.me"
|
"host": "https://akf-forum.glitch.me"
|
||||||
|
|
5
lib.js
5
lib.js
|
@ -1,6 +1,8 @@
|
||||||
const RL = require('express-rate-limit');
|
const RL = require('express-rate-limit');
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require("nodemailer");
|
||||||
const config = require("./config.json");
|
const config = require("./config.json");
|
||||||
|
const crypto = require("crypto");
|
||||||
|
|
||||||
require("dotenv").config();
|
require("dotenv").config();
|
||||||
module.exports = {
|
module.exports = {
|
||||||
threadEnum: ["OPEN", "APPROVAL", "DELETED"],
|
threadEnum: ["OPEN", "APPROVAL", "DELETED"],
|
||||||
|
@ -11,6 +13,9 @@ module.exports = {
|
||||||
handler: (req, res, next, opts) => !req.user?.admin ? res.error(opts.statusCode, "You are begin ratelimited") : next()
|
handler: (req, res, next, opts) => !req.user?.admin ? res.error(opts.statusCode, "You are begin ratelimited") : next()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
getGravatar(email, size) {
|
||||||
|
return `https://www.gravatar.com/avatar/${crypto.createHash('md5').update(email).digest("hex")}?d=mp${size ? `&size=${size}` : ''}`;
|
||||||
|
},
|
||||||
// eslint-disable-next-line no-useless-escape
|
// eslint-disable-next-line no-useless-escape
|
||||||
emailRegEx: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
emailRegEx: /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const mongoose = require("mongoose");
|
const mongoose = require("mongoose");
|
||||||
const cache = require("./cache")
|
const cache = require("./cache")
|
||||||
const MessageModel = require("./Message");
|
const MessageModel = require("./Message");
|
||||||
const { limits, defaultThreadState } = require("../config.json");
|
const { limits, default_thread_state } = require("../config.json");
|
||||||
const { threadEnum } = require("../lib");
|
const { threadEnum } = require("../lib");
|
||||||
const schema = new mongoose.Schema({
|
const schema = new mongoose.Schema({
|
||||||
id: { type: String, unique: true },
|
id: { type: String, unique: true },
|
||||||
|
@ -22,7 +22,7 @@ const schema = new mongoose.Schema({
|
||||||
|
|
||||||
time: { type: Date, default: Date.now },
|
time: { type: Date, default: Date.now },
|
||||||
edited: { type: Boolean, default: false },
|
edited: { type: Boolean, default: false },
|
||||||
state: { type: String, default: defaultThreadState, enum: threadEnum, uppercase: true },
|
state: { type: String, default: default_thread_state, enum: threadEnum, uppercase: true },
|
||||||
messages: [String],
|
messages: [String],
|
||||||
views: { type: Number, default: 0 }
|
views: { type: Number, default: 0 }
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
const { UserModel } = require("../models");
|
const { UserModel } = require("../models");
|
||||||
const { Router } = require("express")
|
const { Router } = require("express")
|
||||||
const bcrypt = require("bcrypt");
|
const bcrypt = require("bcrypt");
|
||||||
const { RL, transporter, emailRegEx } = require('../lib');
|
const { RL, transporter, emailRegEx, getGravatar } = require('../lib');
|
||||||
const app = Router();
|
const app = Router();
|
||||||
const { email_auth, forum_name, host } = require("../config.json");
|
const { email_auth, forum_name, host } = require("../config.json");
|
||||||
app.get("/", (req, res) => res.reply("register", { user: null, discord: req.app.get("discord_auth"), mail: email_auth }));
|
app.get("/", (req, res) => res.reply("register", { user: null, discord: req.app.get("discord_auth"), mail: email_auth }));
|
||||||
|
@ -20,6 +20,8 @@ app.post("/", RL(24 * 60 * 60_000, 5), async (req, res) => {
|
||||||
if (await UserModel.exists({ name })) return res.error(400, `We have got an user named ${name}!`)
|
if (await UserModel.exists({ name })) return res.error(400, `We have got an user named ${name}!`)
|
||||||
const user = new UserModel({ name });
|
const user = new UserModel({ name });
|
||||||
|
|
||||||
|
|
||||||
|
user.avatar = getGravatar(name, 128);
|
||||||
if (about) {
|
if (about) {
|
||||||
if (about.length > 256) return res.error(400, "about must be under 256 characters");
|
if (about.length > 256) return res.error(400, "about must be under 256 characters");
|
||||||
user.about = about;
|
user.about = about;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
Forum description:
|
Forum description:
|
||||||
<input type="text" name="description" value="Akf-forum!" required>
|
<input type="text" name="description" value="Akf-forum!" required>
|
||||||
Default state for new threads, change with "APPROVAL" for approval system:
|
Default state for new threads, change with "APPROVAL" for approval system:
|
||||||
<input type="text" name="defaultThreadState" value="OPEN" required>
|
<input type="text" name="default_thread_state" value="OPEN" required>
|
||||||
Domain of the forum, defaulty setted:
|
Domain of the forum, defaulty setted:
|
||||||
<input type="text" name="host" id="domain" value="Akf-forum!" required>
|
<input type="text" name="host" id="domain" value="Akf-forum!" required>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
Loading…
Reference in a new issue