Commit 88174543 authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Better custom oauth url return.

The authorizePath can include the host itself, so before concacting the host with the authorizePath check if the host is already present in the authorizePath.
parent 77159deb
...@@ -84,7 +84,7 @@ object OauthHelper { ...@@ -84,7 +84,7 @@ object OauthHelper {
* @return The Facebook Oauth URL. * @return The Facebook Oauth URL.
*/ */
fun getFacebookOauthUrl(clientId: String, serverUrl: String, state: String): String { fun getFacebookOauthUrl(clientId: String, serverUrl: String, state: String): String {
return "https://facebook.com/v2.9/dialog/oauth" + return "https://facebook.com/v2.9/dialog/oauth" +
"?client_id=$clientId" + "?client_id=$clientId" +
"&redirect_uri=${serverUrl.removeTrailingSlash()}/_oauth/facebook?close" + "&redirect_uri=${serverUrl.removeTrailingSlash()}/_oauth/facebook?close" +
"&state=$state" + "&state=$state" +
...@@ -113,12 +113,18 @@ object OauthHelper { ...@@ -113,12 +113,18 @@ object OauthHelper {
state: String, state: String,
scope: String scope: String
): String { ): String {
return host + (authorizePath +
authorizePath +
"?client_id=$clientId" + "?client_id=$clientId" +
"&redirect_uri=${serverUrl.removeTrailingSlash()}/_oauth/$serviceName" + "&redirect_uri=${serverUrl.removeTrailingSlash()}/_oauth/$serviceName" +
"&state=$state" + "&state=$state" +
"&scope=$scope" + "&scope=$scope" +
"&response_type=code" "&response_type=code"
).let {
return if (it.contains(host)) {
it
} else {
host + it
}
}
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment