1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-07-17 11:07:42 +02:00

updated oauth2 docs and added create api rule tooltip

This commit is contained in:
Gani Georgiev
2023-04-17 16:29:56 +03:00
parent 00b04db5cf
commit c179b4c473
3 changed files with 32 additions and 14 deletions

View File

@ -1,6 +1,7 @@
<script> <script>
import { slide } from "svelte/transition"; import { slide } from "svelte/transition";
import { Collection } from "pocketbase"; import { Collection } from "pocketbase";
import tooltip from "@/actions/tooltip";
import CommonHelper from "@/utils/CommonHelper"; import CommonHelper from "@/utils/CommonHelper";
import RuleField from "@/components/collections/RuleField.svelte"; import RuleField from "@/components/collections/RuleField.svelte";
@ -79,15 +80,27 @@
<RuleField label="View rule" formKey="viewRule" {collection} bind:rule={collection.viewRule} /> <RuleField label="View rule" formKey="viewRule" {collection} bind:rule={collection.viewRule} />
{#if !collection?.isView} {#if !collection?.$isView}
<RuleField label="Create rule" formKey="createRule" {collection} bind:rule={collection.createRule} /> <RuleField label="Create rule" formKey="createRule" {collection} bind:rule={collection.createRule}>
<svelte:fragment slot="afterLabel" let:isAdminOnly>
{#if !isAdminOnly}
<i
class="ri-information-line link-hint"
use:tooltip={{
text: `The Create rule is executed after a "dry save" of the submitted data, giving you access to the main record fields as in every other rule.`,
position: "top",
}}
/>
{/if}
</svelte:fragment>
</RuleField>
<RuleField label="Update rule" formKey="updateRule" {collection} bind:rule={collection.updateRule} /> <RuleField label="Update rule" formKey="updateRule" {collection} bind:rule={collection.updateRule} />
<RuleField label="Delete rule" formKey="deleteRule" {collection} bind:rule={collection.deleteRule} /> <RuleField label="Delete rule" formKey="deleteRule" {collection} bind:rule={collection.deleteRule} />
{/if} {/if}
{#if collection?.isAuth} {#if collection?.$isAuth}
<RuleField <RuleField
label="Manage rule" label="Manage rule"
formKey="options.manageRule" formKey="options.manageRule"

View File

@ -61,10 +61,15 @@
> >
<div class="input-wrapper"> <div class="input-wrapper">
<label for={uniqueId}> <label for={uniqueId}>
<slot name="beforeLabel" {isAdminOnly} />
<span class="txt" class:txt-hint={isAdminOnly}> <span class="txt" class:txt-hint={isAdminOnly}>
{label} {label}
{isAdminOnly ? "- Admins only" : ""} {isAdminOnly ? "- Admins only" : ""}
</span> </span>
<slot name="afterLabel" {isAdminOnly} />
{#if !isAdminOnly} {#if !isAdminOnly}
<button <button
type="button" type="button"

View File

@ -71,14 +71,14 @@
... ...
// This method initializes a one-off realtime subscription and will // OAuth2 authentication with a single realtime call.
// open a popup window with the OAuth2 vendor page to authenticate.
// //
// Once the external OAuth2 sign-in/sign-up flow is completed, the popup // Make sure to register ${backendAbsUrl}/api/oauth2-redirect as redirect url.
// window will be automatically closed and the OAuth2 data sent back
// to the user through the previously established realtime connection.
const authData = await pb.collection('users').authWithOAuth2({ provider: 'google' }); const authData = await pb.collection('users').authWithOAuth2({ provider: 'google' });
// OR authenticate with manual OAuth2 code exchange
// const authData = await pb.collection('users').authWithOAuth2Code(...);
// after the above you can also access the auth data from the authStore // after the above you can also access the auth data from the authStore
console.log(pb.authStore.isValid); console.log(pb.authStore.isValid);
console.log(pb.authStore.token); console.log(pb.authStore.token);
@ -95,16 +95,16 @@
... ...
// This method initializes a one-off realtime subscription and will // OAuth2 authentication with a single realtime call.
// call the provided urlCallback with the OAuth2 vendor url to authenticate.
// //
// Once the external OAuth2 sign-in/sign-up flow is completed, the browser // Make sure to register ${backendAbsUrl}/api/oauth2-redirect as redirect url.
// window will be automatically closed and the OAuth2 data sent back
// to the user through the previously established realtime connection.
final authData = await pb.collection('users').authWithOAuth2('google', (url) async { final authData = await pb.collection('users').authWithOAuth2('google', (url) async {
await launchUrl(url); await launchUrl(url);
}); });
// OR authenticate with manual OAuth2 code exchange
// final authData = await pb.collection('users').authWithOAuth2Code(...);
// after the above you can also access the auth data from the authStore // after the above you can also access the auth data from the authStore
print(pb.authStore.isValid); print(pb.authStore.isValid);
print(pb.authStore.token); print(pb.authStore.token);