Skip to content

Commit

Permalink
Merge pull request #31 from RaymondFrogParking/signIn_value
Browse files Browse the repository at this point in the history
Update signIn return value
  • Loading branch information
marktefftech authored Feb 8, 2022
2 parents fe590e9 + a4d28b0 commit 13a698b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ enum class Errors(val errorCode: String, val errorMessage: String) {
GENERIC_ERROR("-1100", "Generic Error"),
METHOD_NOT_IMPLEMENTED("-1200", "This method is not implemented"),
NO_CONTEXT("-1300", "No current context exists"),
CANCELLED_ERROR("-1400", "Operation cancelled"),
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,35 @@ fun registerCallback(activity: Activity) {
result[Constants.RESOLVE_TYPE_KEY] = Constants.AUTHORIZED
result[Constants.ACCESS_TOKEN_KEY] = tokens.accessToken

PendingOperation.success(result)
PendingOperation.success(true)

} catch (e: AuthorizationException) {
result[Constants.ERROR_CODE_KEY] = Errors.SIGN_IN_FAILED.errorCode
result[Constants.ERROR_MSG_KEY] = Errors.SIGN_IN_FAILED.errorMessage
//result[Constants.ERROR_CODE_KEY] = Errors.SIGN_IN_FAILED.errorCode
//result[Constants.ERROR_MSG_KEY] = Errors.SIGN_IN_FAILED.errorMessage

PendingOperation.success(result)
PendingOperation.error(Errors.SIGN_IN_FAILED,Errors.SIGN_IN_FAILED.errorMessage )
}
} else if (status == AuthorizationStatus.SIGNED_OUT) {
sessionClient.clear()
result[Constants.RESOLVE_TYPE_KEY] = Constants.SIGNED_OUT
PendingOperation.success(result)
//result[Constants.RESOLVE_TYPE_KEY] = Constants.SIGNED_OUT
PendingOperation.success(true)
} else {
PendingOperation.error(Errors.SIGN_IN_FAILED, Errors.SIGN_IN_FAILED.errorMessage)
}
}

override fun onError(msg: String?, exception: AuthorizationException?) {
val result = mutableMapOf<Any, Any?>()
result[Constants.ERROR_CODE_KEY] = Errors.OKTA_OIDC_ERROR.errorMessage
result[Constants.ERROR_MSG_KEY] = msg
//result[Constants.ERROR_CODE_KEY] = Errors.OKTA_OIDC_ERROR.errorMessage
//result[Constants.ERROR_MSG_KEY] = msg

PendingOperation.success(result)
PendingOperation.error(Errors.OKTA_OIDC_ERROR, Errors.OKTA_OIDC_ERROR.errorMessage,msg)
}

override fun onCancel() {
val result = mutableMapOf<Any, Any?>()
result[Constants.RESOLVE_TYPE_KEY] = Constants.CANCELLED
PendingOperation.success(result)
// val result = mutableMapOf<Any, Any?>()
// result[Constants.RESOLVE_TYPE_KEY] = Constants.CANCELLED
PendingOperation.error(Errors.CANCELLED_ERROR, Errors.CANCELLED_ERROR.errorMessage)
}
}, activity)
}
2 changes: 1 addition & 1 deletion lib/flutter_okta_sdk.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class OktaSDK {
this.isInitialized = true;
}

Future<void> signIn() async {
Future<bool> signIn() async {
if (this.isInitialized == false) {
throw Exception("Cannot sign in before initializing Okta SDK");
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_okta_sdk
description: This library makes it easy to add authentication to flutter apps. This library is a wrapper around Okta OIDC Android and Okta OIDC iOS.
version: 1.0.0-dev.7
version: 1.0.0-dev.8
homepage: https://github.com/sonikro/flutter-okta-sdk

environment:
Expand Down

0 comments on commit 13a698b

Please sign in to comment.