Add web-verification

This commit is contained in:
Nexus 2023-02-23 11:08:57 +00:00
parent b662831193
commit f2780d1f44
Signed by: nex
GPG key ID: 0FA334385D0B689F
4 changed files with 10 additions and 8 deletions

View file

@ -31,7 +31,8 @@ async def send_verification_code(user: discord.User, student_number: str, **kwar
f"Go back to the #verify channel, and click 'I have a verification code!', and put {code} in the modal" f"Go back to the #verify channel, and click 'I have a verification code!', and put {code} in the modal"
f" that pops up\n\n" f" that pops up\n\n"
f"If you have any issues getting in, feel free to reply to this email, or DM eek#7574.\n" f"If you have any issues getting in, feel free to reply to this email, or DM eek#7574.\n"
f"~Nex" f"~Nex\n\n\n"
f"(P.S you can now go to http://droplet.nexy7574.co.uk/jimmy/verify/{code} instead)"
) )
msg = EmailMessage() msg = EmailMessage()
msg["From"] = msg["bcc"] = "B593764@my.leedscitycollege.ac.uk" msg["From"] = msg["bcc"] = "B593764@my.leedscitycollege.ac.uk"

View file

@ -24,7 +24,7 @@ class Bot(commands.Bot):
from .db import JimmyBans, registry from .db import JimmyBans, registry
from .console import console from .console import console
super().__init__( super().__init__(
command_prefix=self.get_prefix, command_prefix=commands.when_mentioned_or("h!", "r!"),
debug_guilds=guilds, debug_guilds=guilds,
allowed_mentions=discord.AllowedMentions.none(), allowed_mentions=discord.AllowedMentions.none(),
intents=intents, intents=intents,

View file

@ -130,7 +130,7 @@ class VerifyView(View):
return await interaction.followup.send(f"\N{cross mark} Failed to send email - {e}. Try again?") return await interaction.followup.send(f"\N{cross mark} Failed to send email - {e}. Try again?")
console.log(f"Sending verification email to {interaction.user} ({interaction.user.id}/{st})...") console.log(f"Sending verification email to {interaction.user} ({interaction.user.id}/{st})...")
name = self.children[1].value name = self.children[1].value
__code = await VerifyCode.objects.create(code=_code, bind=interaction.id, student_id=st, name=name) __code = await VerifyCode.objects.create(code=_code, bind=interaction.user.id, student_id=st, name=name)
console.log( console.log(
f"[green]Sent verification email to {interaction.user} ({interaction.user.id}/{st}): " f"{_code!r}" f"[green]Sent verification email to {interaction.user} ({interaction.user.id}/{st}): " f"{_code!r}"
) )

View file

@ -164,7 +164,7 @@ async def verify(code: str):
status_code=404, status_code=404,
detail="Code not found." detail="Code not found."
) )
# Now we need to fetch the student from the database # Now we need to fetch the student from the database
student = await get_or_none(Student, user_id=verify_code.bind) student = await get_or_none(Student, user_id=verify_code.bind)
if student: if student:
@ -195,8 +195,9 @@ async def verify(code: str):
# And delete the code # And delete the code
await verify_code.delete() await verify_code.delete()
console.log(f"[green]{verify_code.bind} verified ({verify_code.bing}/{verify_code.student_id})") console.log(f"[green]{verify_code.bind} verified ({verify_code.bind}/{verify_code.student_id})")
return { return RedirectResponse(
"message": "Successfully verified." "https://ptb.discord.com/channels/994710566612500550/1018915342317277215/",
} status_code=308
)