Apply suggestions from code review

Co-authored-by: Torsten Dittmann <torsten.dittmann@googlemail.com>
This commit is contained in:
Vincent (Wen Yu) Ge
2024-03-11 14:20:53 +01:00
committed by GitHub
parent cdb5304ac7
commit 8e54df53fd
26 changed files with 87 additions and 99 deletions

View File

@@ -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. 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. 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" /%} {% partial file="account-vs-user.md" /%}
@@ -72,7 +72,7 @@ val account = Account(client)
val user = account.updatePrefs( val user = account.updatePrefs(
prefs = mapOf( prefs = mapOf(
"darkTheme" to true, "darkTheme" to true,
"language" to "en" "language" to "en"
) )
) )
@@ -88,7 +88,7 @@ let account = Account(client)
let user = try await account.updatePrefs( let user = try await account.updatePrefs(
prefs: [ prefs: [
"darkTheme": true, "darkTheme": true,
"language": "en" "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. 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 %} {% multicode %}
```js ```js
import { Client, Account } from "appwrite"; import { Client, Account } from "appwrite";
const client = new Client() const client = new Client()
@@ -175,7 +175,6 @@ query {
You can grant permissions to all users using the `Role.users(<STATUS>)` role or You can grant permissions to all users using the `Role.users(<STATUS>)` role or
individual users using the `Role.user(<USER_ID>, <STATUS>)` role. individual users using the `Role.user(<USER_ID>, <STATUS>)` role.
| Description | Role | | Description | Role |
| ------------------------------------------- | ------------------------------------------- | | ------------------------------------------- | ------------------------------------------- |
| Verified users | `Role.users('verified')`| | Verified users | `Role.users('verified')`|

View File

@@ -10,7 +10,7 @@ Anonymous sessions allow you to implement **guest** users. Guest users let you s
# Create anonymous session {% #createSession %} # 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 %} {% multicode %}
```js ```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. 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" %} {% arrow_link href="/docs/products/auth/email-password" %}
Email and password Email and password
{% /arrow_link %} {% /arrow_link %}
{% arrow_link href="/docs/products/auth/phone-sms" %} {% arrow_link href="/docs/products/auth/phone-sms" %}
Phone (SMS) Phone (SMS)
{% /arrow_link %} {% /arrow_link %}
{% arrow_link href="/docs/products/auth/magic-url" %} {% arrow_link href="/docs/products/auth/magic-url" %}
Magic URL Magic URL
{% /arrow_link %} {% /arrow_link %}
{% arrow_link href="/docs/products/auth/oauth2" %} {% arrow_link href="/docs/products/auth/oauth2" %}
OAuth2 OAuth2
{% /arrow_link %} {% /arrow_link %}

View File

@@ -184,5 +184,5 @@ This would correspond with the permissions below.
| Create | `Permissions.create(Role.label('subscriber'))` | | Create | `Permissions.create(Role.label('subscriber'))` |
{% arrow_link href="/docs/advanced/platform/permissions" %} {% arrow_link href="/docs/advanced/platform/permissions" %}
Learn more about permissions Learn more about permissions
{% /arrow_link %} {% /arrow_link %}

View File

@@ -1,7 +1,7 @@
--- ---
layout: article layout: article
title: Magic URL login 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. 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.

View File

@@ -143,7 +143,6 @@ After creating an OAuth 2 session, you can fetch the session to get information
{% multicode %} {% multicode %}
```js ```js
// Web SDK
import { Client, Account } from "appwrite"; import { Client, Account } from "appwrite";
const client = new Client(); const client = new Client();
@@ -159,7 +158,6 @@ console.log(session.providerAccessToken);
``` ```
```dart ```dart
// Flutter SDK
import 'package:appwrite/appwrite.dart'; import 'package:appwrite/appwrite.dart';
final client = Client() final client = Client()
@@ -179,7 +177,6 @@ print(session.providerAccessToken);
``` ```
```kotlin ```kotlin
// Android SDK
import io.appwrite.Client import io.appwrite.Client
import io.appwrite.services.Account import io.appwrite.services.Account
@@ -200,7 +197,6 @@ print(session.providerAccessToken);
``` ```
```swift ```swift
// Apple SDK
import Appwrite import Appwrite
let client = Client() let client = Client()

View File

@@ -3,7 +3,7 @@ layout: article
title: Start with Authentication title: Start with Authentication
description: Effortlessly add authentication to your apps - simple signup & login in just minutes with Appwrite 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. Adding signup and login is as simple as this.
# Sign up {% #sign-up %} # Sign up {% #sign-up %}
@@ -28,7 +28,7 @@ promise.then(function (response) {
console.log(error); // Failure console.log(error); // Failure
}); });
``` ```
```dart ```dart
import 'package:appwrite/appwrite.dart'; import 'package:appwrite/appwrite.dart';
final client = Client() final client = Client()
@@ -89,7 +89,7 @@ mutation {
# Login {% #login %} # 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 %} {% multicode %}
```js ```js

View File

@@ -4,8 +4,8 @@ title: Teams
description: Master team management in the Appwrite Cloud. Explore team-related functions, permissions, and more. 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. 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. 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. 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. 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( const promise = teams.createMembership(
'teachers', 'teachers',
["maths"], ["maths"],
"david@example.com" "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 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. individual roles in the team using the `Role.team(<TEAM_ID>, [<ROLE_1>, <ROLE_2>, ...])` role.
| Description | Role | | Description | Role |
| ------------------------------------------- | ------------------------------------------- | | ------------------------------------------- | ------------------------------------------- |
| All members | `Role.team(<TEAM_ID>)`| | 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" %} {% arrow_link href="/docs/advanced/platform/permissions" %}
Learn more about permissions Learn more about permissions
{% /arrow_link %} {% /arrow_link %}

View File

@@ -39,13 +39,13 @@
}, },
{ {
title: 'Vue.js', title: 'Vue.js',
icon: 'aw-icon-vue', icon: 'web-icon-vue',
image: '/images/blog/placeholder.png', image: '/images/blog/placeholder.png',
href: 'vue' href: 'vue'
}, },
{ {
title: 'Nuxt', title: 'Nuxt',
icon: 'aw-icon-nuxt', icon: 'web-icon-nuxt',
image: '/images/blog/placeholder.png', image: '/images/blog/placeholder.png',
href: 'nuxt' href: 'nuxt'
}, },
@@ -57,7 +57,7 @@
}, },
{ {
title: 'Refine', title: 'Refine',
icon: 'aw-icon-refine', icon: 'web-icon-refine',
image: '/images/blog/placeholder.png', image: '/images/blog/placeholder.png',
href: 'refine' href: 'refine'
}, },

View File

@@ -105,36 +105,35 @@ interface Todo {
async function prepareDatabase(): Promise<void> { async function prepareDatabase(): Promise<void> {
todoDatabase = await databases.create( todoDatabase = await databases.create(
ID.unique(), ID.unique(),
'TodosDB' 'TodosDB'
); );
todoCollection = await databases.createCollection( todoCollection = await databases.createCollection(
todoDatabase.$id, todoDatabase.$id,
ID.unique(), ID.unique(),
'Todos' 'Todos'
); );
await databases.createStringAttribute( await databases.createStringAttribute(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
'title', 'title',
255, 255,
true true
); );
await databases.createStringAttribute( await databases.createStringAttribute(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
'description', 'description',
255, false, 255, false,
'This is a test description' 'This is a test description'
); );
await databases.createBooleanAttribute( await databases.createBooleanAttribute(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
'isComplete', 'isComplete',
true true
); );
} }
@@ -164,23 +163,22 @@ async function seedDatabase(): Promise<void> {
}; };
await databases.createDocument( await databases.createDocument(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
ID.unique(), ID.unique(),
testTodo1 testTodo1
); );
await databases.createDocument( await databases.createDocument(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
ID.unique(), ID.unique(),
testTodo2 testTodo2
); );
await databases.createDocument( await databases.createDocument(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
ID.unique(), ID.unique(),
testTodo3 testTodo3
); );
} }
@@ -195,7 +193,7 @@ Run the functions to by calling `runAllTasks();`.
```ts ```ts
async function getTodos(): Promise<void> { async function getTodos(): Promise<void> {
const todos = await databases.listDocuments( const todos = await databases.listDocuments(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id todoCollection.$id
); );
@@ -205,7 +203,7 @@ async function getTodos(): Promise<void> {
} }
async function runAllTasks(): Promise<void> { async function runAllTasks(): Promise<void> {
await prepareDatabase(); await prepareDatabase();
await seedDatabase(); await seedDatabase();
await getTodos(); await getTodos();
} }

View File

@@ -59,7 +59,7 @@ npm install node-appwrite
{% /section %} {% /section %}
{% section #step-4 step=4 title="Import Appwrite" %} {% 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 %} {% only_dark %}
![Project settings screen](/images/docs/quick-starts/dark/project-id.png) ![Project settings screen](/images/docs/quick-starts/dark/project-id.png)
@@ -94,36 +94,35 @@ var todoCollection;
async function prepareDatabase() { async function prepareDatabase() {
todoDatabase = await databases.create( todoDatabase = await databases.create(
sdk.ID.unique(), sdk.ID.unique(),
'TodosDB' 'TodosDB'
); );
todoCollection = await databases.createCollection( todoCollection = await databases.createCollection(
todoDatabase.$id, todoDatabase.$id,
sdk.ID.unique(), sdk.ID.unique(),
'Todos' 'Todos'
); );
await databases.createStringAttribute( await databases.createStringAttribute(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
'title', 'title',
255, 255,
true true
); );
await databases.createStringAttribute( await databases.createStringAttribute(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
'description', 'description',
255, false, 255, false,
'This is a test description' 'This is a test description'
); );
await databases.createBooleanAttribute( await databases.createBooleanAttribute(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
'isComplete', 'isComplete',
true true
); );
} }
@@ -153,23 +152,21 @@ async function seedDatabase() {
}; };
await databases.createDocument( await databases.createDocument(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
sdk.ID.unique(), sdk.ID.unique(),
testTodo1 testTodo1
); );
await databases.createDocument( await databases.createDocument(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
sdk.ID.unique(), sdk.ID.unique(),
testTodo2 testTodo2
); );
await databases.createDocument( await databases.createDocument(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id, todoCollection.$id,
sdk.ID.unique(), sdk.ID.unique(),
testTodo3 testTodo3
); );
} }
@@ -184,7 +181,7 @@ Run the functions to by calling `runAllTasks();`.
```js ```js
async function getTodos() { async function getTodos() {
var todos = await databases.listDocuments( var todos = await databases.listDocuments(
todoDatabase.$id, todoDatabase.$id,
todoCollection.$id todoCollection.$id
); );

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/android/step-1'); redirect(303, '/docs/tutorials/android/step-1');
}; };

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/apple/step-1'); redirect(303, '/docs/tutorials/apple/step-1');
}; };

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/flutter/step-1'); redirect(303, '/docs/tutorials/flutter/step-1');
}; };

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/nuxt/step-1'); redirect(303, '/docs/tutorials/nuxt/step-1');
}; };

View File

@@ -27,7 +27,7 @@ const user = useUserSession();
<!-- Email and logout button if logged in user --> <!-- Email and logout button if logged in user -->
<div <div
class="main-header-end u-margin-inline-end-16" class="main-header-end u-margin-inline-end-16"
v-if="user.current.value" v-if="user.current.value"
> >
<p>{{ user.current.providerUid }}</p> <p>{{ user.current.providerUid }}</p>
<button class="button" type="button" @click="user.logout()"> <button class="button" type="button" @click="user.logout()">

View File

@@ -103,7 +103,6 @@ const user = useUserSession();
<IdeasList /> <IdeasList />
</div> </div>
</template> </template>
<style> <style>
article.box { article.box {
background-color: hsl(var(--color-neutral-0)); background-color: hsl(var(--color-neutral-0));

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/react/step-1'); redirect(303, '/docs/tutorials/react/step-1');
}; };

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/refine/step-1'); redirect(303, '/docs/tutorials/refine/step-1');
}; };

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/subscriptions-with-stripe/step-1'); redirect(303, '/docs/tutorials/subscriptions-with-stripe/step-1');
}; };

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { 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');
}; };

View File

@@ -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. 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. 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. Even if you've never tried Appwrite, you will get an idea of what it'll feel like to build with Svelte and Appwrite.

View File

@@ -36,14 +36,14 @@ create-svelte version 3.2.0
└ Your project is ready! └ 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 ```sh
cd my-svelte-project cd my-svelte-project
npm install 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. 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.

View File

@@ -38,7 +38,7 @@ export const appwrite = {
For example, your `.env` might look something similar to this. For example, your `.env` might look something similar to this.
```text ```env
PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1 PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
PUBLIC_APPWRITE_PROJECT=642sdddf85b440dc7e5bf PUBLIC_APPWRITE_PROJECT=642sdddf85b440dc7e5bf
``` ```

View File

@@ -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). 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. 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). Learn more about them in the [authentication guide](https://appwrite.io/docs/products/auth).

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/sveltekit/step-1'); redirect(303, '/docs/tutorials/sveltekit/step-1');
}; };

View File

@@ -2,5 +2,5 @@ import { redirect } from '@sveltejs/kit';
import type { PageLoad } from './$types'; import type { PageLoad } from './$types';
export const load: PageLoad = async () => { export const load: PageLoad = async () => {
throw redirect(303, '/docs/tutorials/vue/step-1'); redirect(303, '/docs/tutorials/vue/step-1');
}; };