我目前正在使用Clearance进行身份验证。作为登录过程的一部分,我想确保我有一个用户的位置(存储在会话中)。
我的问题是如何在清除的情况下这样做?理想情况下,我只想在登录时执行查找(以节省网络流量/ API调用)。如果我找不到用户,那么我将拒绝登录。
我正在考虑使用guard,但我似乎无法访问request.ip
或session
,这有点像交易破坏者。我还试图避免重定向到只进行地理位置的URL,然后重新定向。
任何人都有关于如何使这项工作的好模型的想法?谢谢!
答案 0 :(得分:1)
登录警卫主要用于防止或允许登录的进程。我不认为它们适合这里。对于这个用例,我建议覆盖/*
A ping pong bot, whenever you send "ping", it replies "pong".
*/
// import the discord.js module
const Discord = require('discord.js');
// create an instance of a Discord Client, and call it bot
const bot = new Discord.Client();
// the token of your bot - https://discordapp.com/developers/applications/me
const token = 'your bot token here';
// create an event listener for messages
bot.on('message', message => {
// if the message is "ping",
if (message.content === 'ping') {
// send "pong" to the same channel.
message.channel.sendMessage('pong');
}
});
bot.login(token);
,这通常会混合到sign_in
ApplicationController