mirror of
https://github.com/LukeHagar/website.git
synced 2025-12-10 04:22:18 +00:00
Apply suggestions from code review
Co-authored-by: Torsten Dittmann <torsten.dittmann@googlemail.com>
This commit is contained in:
committed by
GitHub
parent
cdb5304ac7
commit
8e54df53fd
@@ -5,7 +5,7 @@ description: Unlock advanced user management - Appwrite's Account API for seamle
|
||||
---
|
||||
|
||||
Appwrite Account API is used for user signup and login in client applications.
|
||||
Users can be organized into teams and be given labels, so they can be given different permissions and access different resources.
|
||||
Users can be organized into teams and be given labels, so they can be given different permissions and access different resources.
|
||||
Each user's account can also have their own preference object, which you can use to save preferences such as theme, language, and notification settings.
|
||||
|
||||
{% partial file="account-vs-user.md" /%}
|
||||
@@ -72,7 +72,7 @@ val account = Account(client)
|
||||
|
||||
val user = account.updatePrefs(
|
||||
prefs = mapOf(
|
||||
"darkTheme" to true,
|
||||
"darkTheme" to true,
|
||||
"language" to "en"
|
||||
)
|
||||
)
|
||||
@@ -88,7 +88,7 @@ let account = Account(client)
|
||||
|
||||
let user = try await account.updatePrefs(
|
||||
prefs: [
|
||||
"darkTheme": true,
|
||||
"darkTheme": true,
|
||||
"language": "en"
|
||||
]
|
||||
)
|
||||
@@ -111,7 +111,7 @@ mutation {
|
||||
After a user's preferences are updated, they can be retrieved using the [get account preferences](/docs/references/cloud/client-web/account#getPrefs) endpoint.
|
||||
|
||||
{% multicode %}
|
||||
```js
|
||||
```js
|
||||
import { Client, Account } from "appwrite";
|
||||
|
||||
const client = new Client()
|
||||
@@ -175,7 +175,6 @@ query {
|
||||
|
||||
You can grant permissions to all users using the `Role.users(<STATUS>)` role or
|
||||
individual users using the `Role.user(<USER_ID>, <STATUS>)` role.
|
||||
|
||||
| Description | Role |
|
||||
| ------------------------------------------- | ------------------------------------------- |
|
||||
| Verified users | `Role.users('verified')`|
|
||||
|
||||
@@ -10,7 +10,7 @@ Anonymous sessions allow you to implement **guest** users. Guest users let you s
|
||||
|
||||
# Create anonymous session {% #createSession %}
|
||||
|
||||
Create an anonymous session with [Create Anonymous Session](/docs/references/cloud/client-web/account#createAnonymousSession) route.
|
||||
Create an anonymous session with [Create Anonymous Session](/docs/references/cloud/client-web/account#createAnonymousSession) method.
|
||||
|
||||
{% multicode %}
|
||||
```js
|
||||
@@ -83,17 +83,17 @@ Anonymous users cannot sign back in. If the session expires, they move to anothe
|
||||
Create an account with any of these methods to transition from an anonymous session to a user account session.
|
||||
|
||||
{% arrow_link href="/docs/products/auth/email-password" %}
|
||||
Email and password
|
||||
Email and password
|
||||
{% /arrow_link %}
|
||||
|
||||
{% arrow_link href="/docs/products/auth/phone-sms" %}
|
||||
Phone (SMS)
|
||||
Phone (SMS)
|
||||
{% /arrow_link %}
|
||||
|
||||
{% arrow_link href="/docs/products/auth/magic-url" %}
|
||||
Magic URL
|
||||
Magic URL
|
||||
{% /arrow_link %}
|
||||
|
||||
{% arrow_link href="/docs/products/auth/oauth2" %}
|
||||
OAuth2
|
||||
OAuth2
|
||||
{% /arrow_link %}
|
||||
|
||||
@@ -184,5 +184,5 @@ This would correspond with the permissions below.
|
||||
| Create | `Permissions.create(Role.label('subscriber'))` |
|
||||
|
||||
{% arrow_link href="/docs/advanced/platform/permissions" %}
|
||||
Learn more about permissions
|
||||
Learn more about permissions
|
||||
{% /arrow_link %}
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
layout: article
|
||||
title: Magic URL login
|
||||
description: Add magic URL to your authentication in Appwrite. Explore the convenience of passwordless login and email-based authentication using magic links."
|
||||
description: Add magic URL to your authentication in Appwrite. Explore the convenience of passwordless login and email-based authentication using magic links.
|
||||
---
|
||||
|
||||
Magic URL is a password-less way to authenticate users. When a user logs in by providing their email, they will receive an email with a "magic" link that contains a secret used to log in the user. The user can simply click the link to be logged in.
|
||||
|
||||
@@ -143,7 +143,6 @@ After creating an OAuth 2 session, you can fetch the session to get information
|
||||
|
||||
{% multicode %}
|
||||
```js
|
||||
// Web SDK
|
||||
import { Client, Account } from "appwrite";
|
||||
|
||||
const client = new Client();
|
||||
@@ -159,7 +158,6 @@ console.log(session.providerAccessToken);
|
||||
```
|
||||
|
||||
```dart
|
||||
// Flutter SDK
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
final client = Client()
|
||||
@@ -179,7 +177,6 @@ print(session.providerAccessToken);
|
||||
```
|
||||
|
||||
```kotlin
|
||||
// Android SDK
|
||||
import io.appwrite.Client
|
||||
import io.appwrite.services.Account
|
||||
|
||||
@@ -200,7 +197,6 @@ print(session.providerAccessToken);
|
||||
```
|
||||
|
||||
```swift
|
||||
// Apple SDK
|
||||
import Appwrite
|
||||
|
||||
let client = Client()
|
||||
|
||||
@@ -3,7 +3,7 @@ layout: article
|
||||
title: Start with Authentication
|
||||
description: Effortlessly add authentication to your apps - simple signup & login in just minutes with Appwrite Authentication
|
||||
---
|
||||
You can get up and running with Appwrite Authentication in minutes.
|
||||
You can get up and running with Appwrite Authentication in minutes.
|
||||
Adding signup and login is as simple as this.
|
||||
|
||||
# Sign up {% #sign-up %}
|
||||
@@ -28,7 +28,7 @@ promise.then(function (response) {
|
||||
console.log(error); // Failure
|
||||
});
|
||||
```
|
||||
```dart
|
||||
```dart
|
||||
import 'package:appwrite/appwrite.dart';
|
||||
|
||||
final client = Client()
|
||||
@@ -89,7 +89,7 @@ mutation {
|
||||
|
||||
# Login {% #login %}
|
||||
|
||||
After you've created your account, users can be logged in using the [Create Email Session](/docs/references/cloud/client-web/account#createEmailSession) route.
|
||||
After you've created your account, users can be logged in using the [Create Email Session](/docs/references/cloud/client-web/account#createEmailSession) method.
|
||||
|
||||
{% multicode %}
|
||||
```js
|
||||
|
||||
@@ -4,8 +4,8 @@ title: Teams
|
||||
description: Master team management in the Appwrite Cloud. Explore team-related functions, permissions, and more.
|
||||
---
|
||||
|
||||
Teams are a good way to allow users to share access to resources.
|
||||
For example, in a todo app, a user can [create a team](/docs/references/cloud/client-web/teams#create) for one of their todo lists and [invite another user](/docs/references/cloud/client-web/teams#createMembership) to the team to grant the other user access.
|
||||
Teams are a good way to allow users to share access to resources.
|
||||
For example, in a todo app, a user can [create a team](/docs/references/cloud/client-web/teams#create) for one of their todo lists and [invite another user](/docs/references/cloud/client-web/teams#createMembership) to the team to grant the other user access.
|
||||
You can further give special rights to parts of a team using team roles.
|
||||
|
||||
The invited user can [accept the invitation](/docs/references/cloud/client-web/teams#updateMembershipStatus) to gain access. If the user's ever removed from the team, they'll lose access again.
|
||||
@@ -117,7 +117,7 @@ client
|
||||
;
|
||||
|
||||
const promise = teams.createMembership(
|
||||
'teachers',
|
||||
'teachers',
|
||||
["maths"],
|
||||
"david@example.com"
|
||||
);
|
||||
@@ -191,7 +191,6 @@ val response = teams.createMembership(
|
||||
|
||||
You can grant permissions to all members of a team using the `Role.team(<TEAM_ID>)` role or
|
||||
individual roles in the team using the `Role.team(<TEAM_ID>, [<ROLE_1>, <ROLE_2>, ...])` role.
|
||||
|
||||
| Description | Role |
|
||||
| ------------------------------------------- | ------------------------------------------- |
|
||||
| All members | `Role.team(<TEAM_ID>)`|
|
||||
@@ -199,5 +198,5 @@ individual roles in the team using the `Role.team(<TEAM_ID>, [<ROLE_1>, <ROLE_2>
|
||||
|
||||
|
||||
{% arrow_link href="/docs/advanced/platform/permissions" %}
|
||||
Learn more about permissions
|
||||
Learn more about permissions
|
||||
{% /arrow_link %}
|
||||
@@ -39,13 +39,13 @@
|
||||
},
|
||||
{
|
||||
title: 'Vue.js',
|
||||
icon: 'aw-icon-vue',
|
||||
icon: 'web-icon-vue',
|
||||
image: '/images/blog/placeholder.png',
|
||||
href: 'vue'
|
||||
},
|
||||
{
|
||||
title: 'Nuxt',
|
||||
icon: 'aw-icon-nuxt',
|
||||
icon: 'web-icon-nuxt',
|
||||
image: '/images/blog/placeholder.png',
|
||||
href: 'nuxt'
|
||||
},
|
||||
@@ -57,7 +57,7 @@
|
||||
},
|
||||
{
|
||||
title: 'Refine',
|
||||
icon: 'aw-icon-refine',
|
||||
icon: 'web-icon-refine',
|
||||
image: '/images/blog/placeholder.png',
|
||||
href: 'refine'
|
||||
},
|
||||
|
||||
@@ -105,36 +105,35 @@ interface Todo {
|
||||
|
||||
async function prepareDatabase(): Promise<void> {
|
||||
todoDatabase = await databases.create(
|
||||
ID.unique(),
|
||||
ID.unique(),
|
||||
'TodosDB'
|
||||
);
|
||||
|
||||
todoCollection = await databases.createCollection(
|
||||
todoDatabase.$id,
|
||||
ID.unique(),
|
||||
todoDatabase.$id,
|
||||
ID.unique(),
|
||||
'Todos'
|
||||
);
|
||||
|
||||
await databases.createStringAttribute(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'title',
|
||||
255,
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'title',
|
||||
255,
|
||||
true
|
||||
);
|
||||
|
||||
await databases.createStringAttribute(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'description',
|
||||
255, false,
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'description',
|
||||
255, false,
|
||||
'This is a test description'
|
||||
);
|
||||
|
||||
await databases.createBooleanAttribute(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'isComplete',
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'isComplete',
|
||||
true
|
||||
);
|
||||
}
|
||||
@@ -164,23 +163,22 @@ async function seedDatabase(): Promise<void> {
|
||||
};
|
||||
|
||||
await databases.createDocument(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
ID.unique(),
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
ID.unique(),
|
||||
testTodo1
|
||||
);
|
||||
|
||||
await databases.createDocument(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
ID.unique(),
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
ID.unique(),
|
||||
testTodo2
|
||||
);
|
||||
|
||||
await databases.createDocument(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
ID.unique(),
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
ID.unique(),
|
||||
testTodo3
|
||||
);
|
||||
}
|
||||
@@ -195,7 +193,7 @@ Run the functions to by calling `runAllTasks();`.
|
||||
```ts
|
||||
async function getTodos(): Promise<void> {
|
||||
const todos = await databases.listDocuments(
|
||||
todoDatabase.$id,
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id
|
||||
);
|
||||
|
||||
@@ -205,7 +203,7 @@ async function getTodos(): Promise<void> {
|
||||
}
|
||||
|
||||
async function runAllTasks(): Promise<void> {
|
||||
await prepareDatabase();
|
||||
await prepareDatabase();
|
||||
await seedDatabase();
|
||||
await getTodos();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ npm install node-appwrite
|
||||
{% /section %}
|
||||
{% section #step-4 step=4 title="Import Appwrite" %}
|
||||
|
||||
Find your project ID in the **Settings** page. Also, click on the **View API Keys** button to find the API key that was created earlier.
|
||||
Find your project ID in the **Settings** page. Also, click on the **View API Keys** button to find the API key that was created earlier.
|
||||
|
||||
{% only_dark %}
|
||||

|
||||
@@ -94,36 +94,35 @@ var todoCollection;
|
||||
|
||||
async function prepareDatabase() {
|
||||
todoDatabase = await databases.create(
|
||||
sdk.ID.unique(),
|
||||
sdk.ID.unique(),
|
||||
'TodosDB'
|
||||
);
|
||||
|
||||
todoCollection = await databases.createCollection(
|
||||
todoDatabase.$id,
|
||||
sdk.ID.unique(),
|
||||
todoDatabase.$id,
|
||||
sdk.ID.unique(),
|
||||
'Todos'
|
||||
);
|
||||
|
||||
await databases.createStringAttribute(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'title',
|
||||
255,
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'title',
|
||||
255,
|
||||
true
|
||||
);
|
||||
|
||||
await databases.createStringAttribute(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'description',
|
||||
255, false,
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'description',
|
||||
255, false,
|
||||
'This is a test description'
|
||||
);
|
||||
|
||||
await databases.createBooleanAttribute(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'isComplete',
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
'isComplete',
|
||||
true
|
||||
);
|
||||
}
|
||||
@@ -153,23 +152,21 @@ async function seedDatabase() {
|
||||
};
|
||||
|
||||
await databases.createDocument(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
sdk.ID.unique(),
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
sdk.ID.unique(),
|
||||
testTodo1
|
||||
);
|
||||
|
||||
await databases.createDocument(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
sdk.ID.unique(),
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
sdk.ID.unique(),
|
||||
testTodo2
|
||||
);
|
||||
|
||||
await databases.createDocument(
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
sdk.ID.unique(),
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id,
|
||||
sdk.ID.unique(),
|
||||
testTodo3
|
||||
);
|
||||
}
|
||||
@@ -184,7 +181,7 @@ Run the functions to by calling `runAllTasks();`.
|
||||
```js
|
||||
async function getTodos() {
|
||||
var todos = await databases.listDocuments(
|
||||
todoDatabase.$id,
|
||||
todoDatabase.$id,
|
||||
todoCollection.$id
|
||||
);
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/android/step-1');
|
||||
redirect(303, '/docs/tutorials/android/step-1');
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/apple/step-1');
|
||||
redirect(303, '/docs/tutorials/apple/step-1');
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/flutter/step-1');
|
||||
redirect(303, '/docs/tutorials/flutter/step-1');
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/nuxt/step-1');
|
||||
redirect(303, '/docs/tutorials/nuxt/step-1');
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ const user = useUserSession();
|
||||
<!-- Email and logout button if logged in user -->
|
||||
<div
|
||||
class="main-header-end u-margin-inline-end-16"
|
||||
v-if="user.current.value"
|
||||
v-if="user.current.value"
|
||||
>
|
||||
<p>{{ user.current.providerUid }}</p>
|
||||
<button class="button" type="button" @click="user.logout()">
|
||||
|
||||
@@ -103,7 +103,6 @@ const user = useUserSession();
|
||||
<IdeasList />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style>
|
||||
article.box {
|
||||
background-color: hsl(var(--color-neutral-0));
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/react/step-1');
|
||||
redirect(303, '/docs/tutorials/react/step-1');
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/refine/step-1');
|
||||
redirect(303, '/docs/tutorials/refine/step-1');
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/subscriptions-with-stripe/step-1');
|
||||
redirect(303, '/docs/tutorials/subscriptions-with-stripe/step-1');
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/sveltekit-csr-auth/step-1');
|
||||
throw redirect(303, '/docs/tutorials/sveltekit-csr-auth/step-1');
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ category: Auth
|
||||
Appwrite takes away your stress of building and maintaining a backend. Appwrite helps you implement authentication, databases, file storage, and respond to real-time events with **secure** APIs out of the box.
|
||||
If you're a Svelte developer, examples in this guide shows you how Appwrite can help you add authentication to Svelte apps faster.
|
||||
|
||||
## Before you start
|
||||
# Before you start {% #before-you-start %}
|
||||
|
||||
Even if you've never tried Appwrite, you will get an idea of what it'll feel like to build with Svelte and Appwrite.
|
||||
|
||||
|
||||
@@ -36,14 +36,14 @@ create-svelte version 3.2.0
|
||||
└ Your project is ready!
|
||||
```
|
||||
|
||||
After the prompt is finished, you can head over to the newly create project.
|
||||
After the prompt is finished, you can head over to the newly created project.
|
||||
|
||||
```sh
|
||||
cd my-svelte-project
|
||||
npm install
|
||||
```
|
||||
|
||||
## Adding Appwrite to Your Svelte App
|
||||
# Adding Appwrite to your Svelte app {% #adding-appwrite-to-your-svelte-app %}
|
||||
|
||||
Appwrite provides a Web SDK that can be used in your Svelte apps. You can use Appwrite by installing the Web SDK as an NPM package.
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ export const appwrite = {
|
||||
|
||||
For example, your `.env` might look something similar to this.
|
||||
|
||||
```text
|
||||
```env
|
||||
PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
|
||||
PUBLIC_APPWRITE_PROJECT=642sdddf85b440dc7e5bf
|
||||
```
|
||||
|
||||
@@ -6,6 +6,6 @@ step: 7
|
||||
---
|
||||
If you want to see these authentication concepts applied in a more robust manner, you can see them in action in this [demo app](https://github.com/appwrite/getting-started-projects/tree/main/svelte/auth).
|
||||
|
||||
## Other authentication methods
|
||||
# Other authentication methods {% #other-authentication-methods %}
|
||||
Appwrite also supports OAuth, passwordless login, anonymous login, and phone login.
|
||||
Learn more about them in the [authentication guide](https://appwrite.io/docs/products/auth).
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/sveltekit/step-1');
|
||||
redirect(303, '/docs/tutorials/sveltekit/step-1');
|
||||
};
|
||||
|
||||
@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
throw redirect(303, '/docs/tutorials/vue/step-1');
|
||||
redirect(303, '/docs/tutorials/vue/step-1');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user