casauth 2.0.0 copy "casauth: ^2.0.0" to clipboard
casauth: ^2.0.0 copied to clipboard

outdated

CASAuth V2. A third Flutter client SDK for casdoor.

CASAuth #

Build Status Pub Package Coverage Status Package Documentation Github Stars GitHub License

[CASAuth Logo]

CASAuth V2. A third Flutter client SDK for casdoor. Support follow platform:

platform tested example
iOS -
macOS Download
linux [-] -
Windows [-] -

Getting Started #

You need install self's casdoor first. And I only test this SDK with a little version.

Version Casdoor Min Casdoor Max
v1.1.0 ✅ v1.97.0 -
v1.1.0 ✅ v1.123.0 -
v1.2.0 ✅ v1.223.0 -
v2.0.0 ✅ v1.308.0 -

Quick Start #

I will show howto use this SDK follow.

If casdoor server response status is error or code not 200, the SDK will thorws CASAuthError, that has 3 error level warn /error / fatal. warn error dont need process; error will case current method/request failed only; when there has fatal error, your all methods calling maybe failed.

Before start calling methods, you MUST initiate the SDK.

initiate #

// init global instance
import 'package:casauth/casauth.dart';

String appId = "some-app-id";
String appName = "app-example";
String orgnazationName = "casbin";
String server = "https://door.casdoor.com";

try {
  //  Normally we use the default global instance to access casdoor.
  await init(appName, appId, server, orgnazationName);
  // Otherwise, you can create instance and manage it by your self.
  // var sdk = CASAuth(appName, appId, server, orgnazationName)
  // await sdk.init();
} catch (e) {
  debugPrint("init casauth SDK failed: $e");
}

CASAuth and global init method has optional parameters:

  • vault: Vault of Stash package, CASAuth use it to cache token, user info etc. And we will default init sqlite database if not set vault parameter. You can initiate any stash Storage Implementations and create vault to customs storage for the SDK.
  • userPrefix: Random user name prefix. Default value is mobile_.
  • redirectUri: Address configured at Casdoor application config, the value must in the application's callback list. We use it to revoke/expired JWT token. Default value is casauth.

Send code #

When the user register or recover password, must send verification code to the target email/mobile phone.

try {
  AuthResult resp = await casauth.sendCode(email, type: AccountType.email);
} catch (e) {
  debugPrint("send code failed");
}

Signup/Register by email #

try {
  await casauth.registerByEmail(email, code, username: id, password: id);
} catch (e) {
  debugPrint("register user failed");
}
1
likes
0
points
42
downloads

Publisher

unverified uploader

Weekly Downloads

CASAuth V2. A third Flutter client SDK for casdoor.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, http, stash, stash_sqlite, xid

More

Packages that depend on casauth