Skip to content
Flutter user authentication with back-end handler
Dart Ruby Objective-C Java Shell
Branch: master
Clone or download
Mohamed Sayed Mohamed Sayed
Mohamed Sayed and Mohamed Sayed [docs]
Latest commit 405c7ae Jan 2, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.idea init Nov 28, 2019
android init Nov 28, 2019
example [docs] Jan 2, 2020
ios init Nov 28, 2019
lib added register Dec 2, 2019
.gitignore init Nov 28, 2019
.metadata init Nov 28, 2019
CHANGELOG.md [docs] Jan 2, 2020
LICENSE
README.md [docs] Jan 2, 2020
logo.png enhancement Dec 28, 2019
pubspec.lock [FIX} Dec 27, 2019
pubspec.yaml [docs] Jan 2, 2020
user_auth.iml init Nov 28, 2019

README.md

user_auth

Handy flutter plugin that help with user-backend-auth, written in pure dart code, in top of http and shared_preferences.

usage

  • import package:user_auth/user_auth.dart.
  • create instance from UserAuth.
  • init with apiBaseUrl and optional store: true | false, default is false, if true plugin will store user and retrieve with loadUser().
  • initialize plugin with api_base_url.

methods

you may change routes to fit your API
  • login : default route /user/login, waits for user in response to return.
  • check : default route /user/details, waits for user in response to return.
  • logout : default route /user/details, return true | false.
  • loadUser : local method, return user if stored.
  • Newregister : default route /user/register, waits for user in response to return.

example

import 'package:user_auth/user_auth.dart';

// instance
UserAuth user = new UserAuth();

// init
await user.init(
    apiBaseUrl: 'https://example.com/api',
    store: true,
  );

// Note : change 'Bearer ' and api_token with your own parameters

// login
var activeUser = loadedUser = await user.login(
                    usernameVar: 'email',
                    usernameVal: 'test@test.com',
                    password: '12345678',
                  );

// check
var checkedUser = await user.check(
                    type: 'Bearer ',
                    token: activeUser['api_token'],
                  ); 

// logout
var logout = await user.logout(
                    type: 'Bearer ',
                    token: activeUser['api_token'],
                  );

// register
Map form = {
            "email" : "test@test.com",
            "phone" : "00000000",
            "name" : "mohamed sayed",
            "password" : "1234567",
            };
registeredUser = await user.register(form: form);

Author

Mohamed Sayed

  • LinkedIn   Fork   Star   Watches
  • Plugin   Example

My Plugins

You can’t perform that action at this time.