user_auth 1.2.2 copy "user_auth: ^1.2.2" to clipboard
user_auth: ^1.2.2 copied to clipboard

discontinued

Dart - Backend user auth helpe, with common methods like login and register

user_auth #

Dart - Backend user auth helpe, with common methods

Pub Example

Show some ❤️ and star the repo #

Fork Star Watch

usage #

  • import package:user_auth/user_auth.dart.
  • create instance from UserAuth.
  • init with apiBaseUrl and other parameters.

methods #

  • login : waits for user in response to return.
  • check : waits for user in response to return.
  • logout : return true | false.
  • loadUser : return user if stored in prefs.
  • register : waits for user in response to return.

example #

import 'package:user_auth/user_auth.dart';

// instance
UserAuth user = new UserAuth();

// init
SharedPreferences prefs = await SharedPreferences.getInstance();
  await user.init(
    apiBaseUrl: 'https://example.com/api',
    store: true,
    prefs: prefs, // need if store: true
    loginUrl: "/user/login",
    registerUrl: "/user/register",
    checkUrl: "/user/details",
    logoutUrl: "/user/logout",
  );

// 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);

Project Created & Maintained By #

Mohamed Sayed #

Software Engineer | In ❤️ with Flutter

Donate #

If you found this project helpful or you learned something from the source code and want to thank me, consider buying me a cup of ☕

Note : All Contibutions Are Welcomed #

16
likes
40
pub points
0%
popularity

Publisher

verified publishermsayed.net

Dart - Backend user auth helpe, with common methods like login and register

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

http

More

Packages that depend on user_auth