mirror of
https://github.com/OpenBankProject/API-Explorer.git
synced 2026-02-06 10:47:23 +00:00
feature/added the error handling for the oauth
This commit is contained in:
parent
594d6578f5
commit
befd4da0cf
@ -189,10 +189,20 @@ object OAuthClient extends MdcLoggable {
|
||||
logger.debug("redirect says: credential.provider: " + credential.provider)
|
||||
logger.debug("redirect says: oauthcallbackUrl: " + oauthcallbackUrl)
|
||||
credential.consumer.setMessageSigner(new HmacSha256MessageSigner())
|
||||
val authUrl = provider.oAuthProvider.retrieveRequestToken(credential.consumer, oauthcallbackUrl)
|
||||
logger.debug("redirect says: authUrl: " + authUrl)
|
||||
val authUrlBox = tryo {provider.oAuthProvider.retrieveRequestToken(credential.consumer, oauthcallbackUrl)}
|
||||
|
||||
if(authUrlBox.isInstanceOf[Failure]) {
|
||||
val errorMessage = "Critical exception happened on the backend: " + authUrlBox.asInstanceOf[Failure].messageChain
|
||||
logger.error(errorMessage)
|
||||
throw new Exception(errorMessage)
|
||||
} else if(authUrlBox.isEmpty){
|
||||
logger.error("Critical exception happened on backend: oauth callback Url is empty! Please check the consumer key and secret first.")
|
||||
throw new Exception("Critical exception happened on backend: oauth callback Url is empty! Please check the consumer key and secret first.")
|
||||
} else{
|
||||
logger.debug("redirect says: authUrlBox: " + authUrlBox.head)
|
||||
S.redirectTo(authUrlBox.head)
|
||||
}
|
||||
|
||||
S.redirectTo(authUrl)
|
||||
}
|
||||
|
||||
def redirectToConnectBankAccount() = {
|
||||
|
||||
@ -35,10 +35,10 @@ package code.snippet
|
||||
import net.liftweb.http.js.JsCmd
|
||||
import net.liftweb.util.Helpers
|
||||
import Helpers._
|
||||
import net.liftweb.http.SHtml
|
||||
import net.liftweb.http.{ResponseShortcutException, SHtml}
|
||||
import code.lib.{OAuthClient, ObpAPI}
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.http.js.JsCmds.Noop
|
||||
import net.liftweb.http.js.JsCmds.{Alert, Noop}
|
||||
|
||||
class Login {
|
||||
private def getDisplayNameOfUser(): Box[String] = {
|
||||
@ -69,8 +69,17 @@ class Login {
|
||||
".logged-in *" #> "" &
|
||||
"#start-login [onclick]" #> {
|
||||
def actionJS: JsCmd = {
|
||||
OAuthClient.redirectToOauthLogin()
|
||||
Noop
|
||||
try {
|
||||
OAuthClient.redirectToOauthLogin()
|
||||
}
|
||||
catch {
|
||||
//this is the Liftweb redirect mechanism, it will throw the ResponseShortcutException.
|
||||
case e: ResponseShortcutException =>
|
||||
OAuthClient.redirectToOauthLogin()
|
||||
Noop
|
||||
case e: Throwable =>
|
||||
Alert(e.getMessage)
|
||||
}
|
||||
}
|
||||
SHtml.onEvent((s: String) => actionJS)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user