mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2023-12-13 20:50:18 +01:00
42 lines
733 B
Java
42 lines
733 B
Java
|
package org.mian.gitnex.helpers;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import okhttp3.Credentials;
|
||
|
|
||
|
/**
|
||
|
* Author M M Arif
|
||
|
*/
|
||
|
|
||
|
public class Authorization {
|
||
|
|
||
|
public static String returnAuthentication(Context context, String loginUid, String token) {
|
||
|
|
||
|
TinyDB tinyDb = new TinyDB(context);
|
||
|
|
||
|
String credential;
|
||
|
|
||
|
if(tinyDb.getBoolean("basicAuthFlag")) {
|
||
|
|
||
|
if (!tinyDb.getString("basicAuthPassword").isEmpty()) {
|
||
|
|
||
|
credential = Credentials.basic(loginUid, tinyDb.getString("basicAuthPassword"));
|
||
|
|
||
|
}
|
||
|
else {
|
||
|
|
||
|
credential = token;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else {
|
||
|
|
||
|
credential = token;
|
||
|
|
||
|
}
|
||
|
|
||
|
return credential;
|
||
|
|
||
|
}
|
||
|
|
||
|
}
|