nuxt-atproto 0.0.3 → 0.0.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/README.md
CHANGED
|
@@ -230,20 +230,22 @@ Logs out the currently authenticated user and clears the stored session data.
|
|
|
230
230
|
|
|
231
231
|
<br />
|
|
232
232
|
|
|
233
|
-
###
|
|
233
|
+
### ➡️ isLogged()
|
|
234
234
|
|
|
235
|
-
|
|
235
|
+
Indicates whether the user is currently authenticated.
|
|
236
236
|
|
|
237
237
|
```ts
|
|
238
238
|
const atproto = useAtproto()
|
|
239
239
|
|
|
240
|
-
|
|
241
|
-
console.log(
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
240
|
+
if (atproto.isLogged()) {
|
|
241
|
+
console.log('User is authenticated')
|
|
242
|
+
} else {
|
|
243
|
+
console.log('User is not logged in')
|
|
244
|
+
}
|
|
245
245
|
```
|
|
246
246
|
|
|
247
|
+
**Returns**: Returns a boolean indicating whether the user is authenticated.
|
|
248
|
+
|
|
247
249
|
<br />
|
|
248
250
|
|
|
249
251
|
## 🧩 useAgent(service?: string, fetch?: any)
|
package/dist/module.json
CHANGED
|
@@ -4,5 +4,5 @@ export declare function useAtproto(service?: string, fetch?: any): {
|
|
|
4
4
|
signInWithHandle: (handle?: string, options?: any) => Promise<void>;
|
|
5
5
|
signOut: () => Promise<void>;
|
|
6
6
|
restore: (did: string) => Promise<OAuthSession>;
|
|
7
|
-
|
|
7
|
+
isLogged: () => any;
|
|
8
8
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { useRuntimeConfig, useNuxtApp } from "nuxt/app";
|
|
2
|
-
import { useAgent } from "./useAgent.js";
|
|
3
2
|
export function useAtproto(service, fetch) {
|
|
4
3
|
const runtimeConfig = useRuntimeConfig();
|
|
5
4
|
async function signIn(serviceEndpoint = runtimeConfig.public.atproto.serviceEndpoint.private, options = runtimeConfig.public.atproto.oauth.signInOptions) {
|
|
@@ -47,12 +46,15 @@ export function useAtproto(service, fetch) {
|
|
|
47
46
|
console.log("User signed out");
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
function isLogged() {
|
|
50
|
+
const { $atproto } = useNuxtApp();
|
|
51
|
+
return $atproto.session.value;
|
|
52
|
+
}
|
|
51
53
|
return {
|
|
52
54
|
signIn,
|
|
53
55
|
signInWithHandle,
|
|
54
56
|
signOut,
|
|
55
57
|
restore,
|
|
56
|
-
|
|
58
|
+
isLogged
|
|
57
59
|
};
|
|
58
60
|
}
|