@mikandev/next-discord-auth 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/redirect.js CHANGED
@@ -24,10 +24,10 @@ export const handleRedirect = async (req) => {
24
24
  const userData = (await sessionData.json());
25
25
  const session = {
26
26
  user: {
27
- id: userData.user.id,
28
- name: `${userData.user.username}#${userData.user.discriminator}`,
29
- email: userData.user.email,
30
- avatar: `https://cdn.discordapp.com/avatars/${userData.user.id}/${userData.user.avatar}.png`,
27
+ id: userData.id,
28
+ name: `${userData.username}`,
29
+ email: userData.email,
30
+ avatar: `https://cdn.discordapp.com/avatars/${userData.id}/${userData.avatar}.png`
31
31
  },
32
32
  expires: new Date(Date.now() + response.expiresIn * 1000).toISOString(),
33
33
  };
@@ -1,5 +1,6 @@
1
1
  import { NextRequest, NextResponse } from "next/server";
2
2
  import { cookies } from "next/headers";
3
+ import { redirect } from "next/navigation";
3
4
  import { getGlobalConfig } from "./index";
4
5
  import jwt from "jsonwebtoken";
5
6
  export const getSession = async () => {
@@ -16,14 +17,14 @@ export const getSession = async () => {
16
17
  return null;
17
18
  }
18
19
  };
19
- export const signIn = async (req) => {
20
+ export const signIn = async () => {
20
21
  const config = getGlobalConfig();
21
22
  const session = await getSession();
22
23
  if (session) {
23
24
  return NextResponse.json({ message: "Already signed in" }, { status: 200 });
24
25
  }
25
26
  const signInURL = `https://discord.com/api/oauth2/authorize?client_id=${config.clientId}&redirect_uri=${encodeURIComponent(config.redirectUri)}&response_type=code&scope=${config.scopes.join(" ")}`;
26
- return NextResponse.redirect(signInURL, 302);
27
+ return redirect(signInURL);
27
28
  };
28
29
  export const signOut = async () => {
29
30
  const config = getGlobalConfig();
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "main": "dist/index.js",
7
7
  "files": ["dist"],
8
8
  "license": "WTFPL",
9
- "version": "0.1.2",
9
+ "version": "0.1.4",
10
10
  "type": "module",
11
11
  "repository": {
12
12
  "type": "git",