@mikandev/next-discord-auth 0.1.2 → 0.1.3
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/server-actions.js +3 -2
- package/package.json +1 -1
package/dist/server-actions.js
CHANGED
|
@@ -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 (
|
|
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
|
|
27
|
+
return redirect(signInURL);
|
|
27
28
|
};
|
|
28
29
|
export const signOut = async () => {
|
|
29
30
|
const config = getGlobalConfig();
|