https://github.com/khadkarajesh/auth
Authentication module
https://github.com/khadkarajesh/auth
android-architecture-components android-ktx android-library authentication kotlin-android kotlin-coroutines retrofit2 reusable-components
Last synced: about 1 year ago
JSON representation
Authentication module
- Host: GitHub
- URL: https://github.com/khadkarajesh/auth
- Owner: khadkarajesh
- Created: 2018-11-16T10:29:40.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-11-20T12:03:17.000Z (over 7 years ago)
- Last Synced: 2025-03-02T23:41:52.924Z (over 1 year ago)
- Topics: android-architecture-components, android-ktx, android-library, authentication, kotlin-android, kotlin-coroutines, retrofit2, reusable-components
- Language: Kotlin
- Size: 193 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Auth
Authentication module
# Uses
Add in Application class
## Step 1
Add config on applcations ```onCreate()```
```
var endPoint = EndPoint.Builder()
.baseUrl("your_base_url")
.login("auth/authenticate")
.forgotPassword("password/reset")
.resetPassword("password/reset")
.build()
AuthConfig.setEndpoint(endPoint)
```
## Step 2
Register event to get response
```
EventBus.register(this)
```
Get Response as:
```
@Subscribe
fun onSuccess(event: AuthEvent) {
when (event) {
is LoginSuccess -> {
// your result
}
}
}
```
# Deserialize Response Body BaseResponse
```
class BaseResponse {
@SerializedName("body")
val body: R? = null
}
```
```
var gson = Gson()
var baseResponse: BaseResponse = Gson().fromJson(event.result.string(), gson.getType(BaseResponse::class.java, User::class.java))
Log.d("login success", "called " + baseResponse.body?.firstName)
this.startActivity(Intent(this, DashboardActivity::class.java))
```