Coder Social home page Coder Social logo

vinayak90 / sessionmanager Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rlichtarski/sessionmanager

0.0 0.0 0.0 8.94 MB

Login/register app using Reqres REST API with auto-re-authentication when the app launches. The app uses MVVM architecture with Jetpack (Room, ViewModel, LiveData, DataStore, View Binding), Hilt, Coroutines, Flows, etc...

Kotlin 100.00%

sessionmanager's Introduction

SessionManager

Faking login/register app using Reqres REST API with auto-re-authentication when the app launches. The app uses MVVM architecture with Jetpack (Room, ViewModel, LiveData, DataStore, View Binding), Hilt, Coroutines, Flows, etc...

Project features

This app uses some modern Android tech stacks & libraries:

  • 100% Kotlin + Coroutines + Flow for asynchronus
  • Hilt - for dependency injection.
  • Retrofit2 - A type-safe HTTP client for Android.
  • Moshi - a modern JSON library for Android.
  • JetPack:
    • LiveData - observable data holder class.
    • ViewModel - store and manage UI-related data in a lifecycle conscious way.
    • Room Persistence - local database.
    • ViewBinding - interact with views (replacement for findViewById).
    • DataStore - replacement for SharedPreferences - allows to store key-value pairs.
  • Architecture:
    • MVVM Architecture
    • Repository pattern with use-cases.
    • Mapping local entities and remote data transfer objects (DTOs) into Domain Model.
  • Timber - logging.

Open API (Reqres)

SessionManager uses the Reqres REST API for faking login/registration and receiving an auth token. Reqres simulates real application scenarios. If you want to test a user authentication system, Reqres will respond to a successful login/register request with a token for you to identify a sample user, or with a 403 forbidden response to an unsuccessful login/registration attempt. With Reqres you can only login/register with predefined users.

How does auto-authentication work?

When a user successfully logs in or registers, the user's email gets saved into the DataStore (the key-value email denotes what the previously authenticated user was). When the app opens the next time, the first thing that is checked is this email key-value. Then the email is used to query the token from the Room Persistence library.
If the token is found, the user is automatically authenticated. If the token isn't found, the user won't be authenticated.
When the user logs out, the token is deleted from the database, so even though the email is still in the DataStore, the token will never be found, so the user won't be authenticated

sessionmanager's People

Contributors

rlichtarski avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.