Skip to content

Commit

Permalink
Merge pull request #11 from lohanidamodar/feat-0.15
Browse files Browse the repository at this point in the history
updates to support appwrite 0.15
  • Loading branch information
lohanidamodar committed Jul 4, 2022
2 parents b5f72ce + ff32ccb commit bbf9f1d
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.3.0]
* Upgrade to support Appwrite 0.15
* More on Appwrite's [Flutter SDK Changelog](https://pub.dev/packages/appwrite/changelog#600)

## [0.2.1]
* Fix export issues

Expand Down
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class _LoginPageState extends State<LoginPage> {
final password = _password.text;

if (!await context.authNotifier
.createSession(email: email, password: password)) {
.createEmailSession(email: email, password: password)) {
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
content: Text(context.authNotifier.error ??
"Unknown error")));
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ packages:
name: appwrite
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
version: "6.0.0"
appwrite_auth_kit:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.2.1"
version: "0.3.0"
async:
dependency: transitive
description:
Expand Down
56 changes: 53 additions & 3 deletions lib/src/accounts_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class AuthNotifier extends ChangeNotifier {
}
}

Future<bool> createSession({
Future<bool> createEmailSession({
required String email,
required String password,
bool notify = true,
Expand All @@ -111,7 +111,7 @@ class AuthNotifier extends ChangeNotifier {
notifyListeners();
}
try {
await _account.createSession(email: email, password: password);
await _account.createEmailSession(email: email, password: password);
_getUser(notify: notify);
return true;
} on AppwriteException catch (e) {
Expand All @@ -124,6 +124,41 @@ class AuthNotifier extends ChangeNotifier {
}
}

Future<bool> createPhoneSession({
required String userId,
required String number,
}) async {
_status = AuthStatus.authenticating;
notifyListeners();
try {
await _account.createPhoneSession(userId: userId, number: number);
return true;
} on AppwriteException catch (e) {
_error = e.message;
_status = AuthStatus.unauthenticated;
notifyListeners();
return false;
}
}

Future<bool> updatePhoneSession({
required String userId,
required String secret,
}) async {
_status = AuthStatus.authenticating;
notifyListeners();
try {
await _account.updatePhoneSession(userId: userId, secret: secret);
await _getUser();
return true;
} on AppwriteException catch (e) {
_error = e.message;
_status = AuthStatus.unauthenticated;
notifyListeners();
return false;
}
}

Future<bool> createAnonymousSession() async {
_status = AuthStatus.authenticating;
notifyListeners();
Expand Down Expand Up @@ -205,7 +240,7 @@ class AuthNotifier extends ChangeNotifier {
userId: userId, name: name, email: email, password: password);
_error = '';
if (newSession) {
await createSession(email: email, password: password);
await createEmailSession(email: email, password: password);
}
return user;
} on AppwriteException catch (e) {
Expand Down Expand Up @@ -307,6 +342,21 @@ class AuthNotifier extends ChangeNotifier {
}
}

Future<User?> updatePhone({
required String number,
required String password,
}) async {
try {
_user = await _account.updatePhone(number: number, password: password);
notifyListeners();
return _user;
} on AppwriteException catch (e) {
_error = e.message;
notifyListeners();
return null;
}
}

Future<User?> updateEmail({
required String email,
required String password,
Expand Down
48 changes: 24 additions & 24 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: appwrite
url: "https://pub.dartlang.org"
source: hosted
version: "5.0.0"
version: "6.0.0"
async:
dependency: transitive
description:
Expand Down Expand Up @@ -63,14 +63,14 @@ packages:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
version: "3.0.2"
device_info_plus:
dependency: transitive
description:
name: device_info_plus
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.3"
version: "3.2.4"
device_info_plus_linux:
dependency: transitive
description:
Expand All @@ -91,7 +91,7 @@ packages:
name: device_info_plus_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
version: "2.3.0+1"
device_info_plus_web:
dependency: transitive
description:
Expand Down Expand Up @@ -119,14 +119,14 @@ packages:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.2.1"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "6.1.0"
version: "6.1.2"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -138,7 +138,7 @@ packages:
name: flutter_lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
version: "2.0.1"
flutter_test:
dependency: "direct dev"
description: flutter
Expand Down Expand Up @@ -169,7 +169,7 @@ packages:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
version: "4.0.1"
js:
dependency: transitive
description:
Expand All @@ -183,7 +183,7 @@ packages:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
version: "2.0.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -260,70 +260,70 @@ packages:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.9"
version: "2.0.11"
path_provider_android:
dependency: transitive
description:
name: path_provider_android
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.11"
version: "2.0.16"
path_provider_ios:
dependency: transitive
description:
name: path_provider_ios
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.7"
version: "2.0.10"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.2"
version: "2.1.7"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.6"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
version: "2.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
version: "2.0.7"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.0"
version: "3.1.0"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.2"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.1"
version: "4.2.4"
sky_engine:
dependency: transitive
description: flutter
Expand Down Expand Up @@ -377,7 +377,7 @@ packages:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "1.3.1"
vector_math:
dependency: transitive
description:
Expand All @@ -398,14 +398,14 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.5"
version: "2.6.1"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
version: "0.2.0+1"
sdks:
dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.5.0"
dart: ">=2.17.0 <3.0.0"
flutter: ">=3.0.0"
9 changes: 4 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
name: appwrite_auth_kit
description: A wrapper for Appwrite's Accounts service, makes it easy to use
Accounts service, manage authentication and account features.
version: 0.2.1
description: A wrapper for Appwrite's Accounts service, makes it easy to manage authentication and account features.
version: 0.3.0
homepage: https://github.com/lohanidamodar/appwrite_auth_kit

environment:
sdk: ">=2.12.0 <3.0.0"
flutter: ">=2.0.0"

dependencies:
appwrite: ^5.0.0
appwrite: ^6.0.0
flutter:
sdk: flutter

dev_dependencies:
flutter_lints: ^1.0.4
flutter_lints: ^2.0.1
flutter_test:
sdk: flutter

Expand Down

0 comments on commit bbf9f1d

Please sign in to comment.