Back

Account not in SDK

  • 0
  • Flutter
  • Accounts
renderlux
22 May, 2023, 09:11

Hi All

Flutter appwrite: ^9.0.0

TypeScript
  FutureEither<model.Account> signUp({
    required String email,
    required String password,
  });

Can't find Account

The name 'model.Account' isn't a type, so it can't be used as a type argument. Try correcting the name to an existing type, or defining a type named 'model.Account'

TL;DR
The user is having trouble finding the 'Account' model in the SDK version 9.0.0. They are asking why it is not present in this version. The solution is to upgrade the SDK to the latest version, which includes the 'User' model as a replacement for 'Account'.
renderlux
22 May, 2023, 09:25

But it's in 8.2.0 SDK but not 9

D5
22 May, 2023, 09:27

What you're trying to achieve?

D5
22 May, 2023, 09:28

@renderlux

renderlux
22 May, 2023, 09:29

Sign up and login

Vedsaga
22 May, 2023, 09:30

yap, it have been replaced with User

renderlux
22 May, 2023, 09:30

But I'm also asking why Account model is in 8 but not in 9

renderlux
22 May, 2023, 09:30

OK I see

Vedsaga
22 May, 2023, 09:31
TypeScript

part of appwrite.models;

/// User
class User implements Model {
  /// User ID.
  final String $id;

  /// User creation date in ISO 8601 format.
  final String $createdAt;

  /// User update date in ISO 8601 format.
  final String $updatedAt;

  /// User name.
  final String name;

  /// Hashed user password.
  final String? password;

  /// Password hashing algorithm.
  final String? hash;

  /// Password hashing algorithm configuration.
  final Map? hashOptions;

  /// User registration date in ISO 8601 format.
  final String registration;

  /// User status. Pass `true` for enabled and `false` for disabled.
  final bool status;

  /// Password update time in ISO 8601 format.
  final String passwordUpdate;

  /// User email address.
  final String email;

  /// User phone number in E.164 format.
  final String phone;

  /// Email verification status.
  final bool emailVerification;

  /// Phone verification status.
  final bool phoneVerification;
D5
22 May, 2023, 09:49

Upgrade SDK to last version

D5
22 May, 2023, 09:51

Login is that way:

TypeScript
import { Client, Account } from "appwrite";

const client = new Client();

const account = new Account(client);

client
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

const promise = account.createEmailSession('email@example.com', 'password');

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});
D5
22 May, 2023, 09:52

And to sign up:

TypeScript
import { Client, Account } from "appwrite";

const client = new Client();

const account = new Account(client);

client
    .setEndpoint('https://cloud.appwrite.io/v1') // Your API Endpoint
    .setProject('5df5acd0d48c2') // Your project ID
;

const promise = account.create('[USER_ID]', 'email@example.com', '');

promise.then(function (response) {
    console.log(response); // Success
}, function (error) {
    console.log(error); // Failure
});
D5
22 May, 2023, 09:52

account.create instead of account.createemailsession

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more