mirror of
https://codeberg.org/gitnex/GitNex.git
synced 2024-12-16 15:48:13 +08:00
Merge branch 'master' into 400-milestone-bug
This commit is contained in:
commit
9a5a774d8c
@ -377,7 +377,6 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
tinyDb.putString("instanceUrlRaw", instanceHost);
|
tinyDb.putString("instanceUrlRaw", instanceHost);
|
||||||
//tinyDb.putString("loginUid", loginUid);
|
|
||||||
tinyDb.putString("instanceUrl", instanceUrl);
|
tinyDb.putString("instanceUrl", instanceUrl);
|
||||||
tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol);
|
tinyDb.putString("instanceUrlWithProtocol", instanceUrlWithProtocol);
|
||||||
|
|
||||||
@ -414,10 +413,28 @@ public class LoginActivity extends BaseActivity implements View.OnClickListener
|
|||||||
|
|
||||||
private void versionCheck(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP, final String loginToken_, final int loginType) {
|
private void versionCheck(final String instanceUrl, final String loginUid, final String loginPass, final int loginOTP, final String loginToken_, final int loginType) {
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion = RetrofitClient
|
Call<GiteaVersion> callVersion;
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
if (!loginToken_.isEmpty()) {
|
||||||
.getApiInterface()
|
callVersion = RetrofitClient
|
||||||
.getGiteaVersion();
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.getGiteaVersionWithToken(loginToken_);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final String credential = Credentials.basic(loginUid, loginPass, StandardCharsets.UTF_8);
|
||||||
|
if (loginOTP != 0) {
|
||||||
|
callVersion = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.getGiteaVersionWithOTP(credential,loginOTP);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
callVersion = RetrofitClient
|
||||||
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
|
.getApiInterface()
|
||||||
|
.getGiteaVersionWithBasic(credential);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
|
@ -404,10 +404,12 @@ public class MainActivity extends BaseActivity implements NavigationView.OnNavig
|
|||||||
|
|
||||||
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
final TinyDB tinyDb = new TinyDB(getApplicationContext());
|
||||||
|
|
||||||
|
final String token = "token " + tinyDb.getString(tinyDb.getString("loginUid") + "-token");
|
||||||
|
|
||||||
Call<GiteaVersion> callVersion = RetrofitClient
|
Call<GiteaVersion> callVersion = RetrofitClient
|
||||||
.getInstance(instanceUrl, getApplicationContext())
|
.getInstance(instanceUrl, getApplicationContext())
|
||||||
.getApiInterface()
|
.getApiInterface()
|
||||||
.getGiteaVersion();
|
.getGiteaVersionWithToken(token);
|
||||||
|
|
||||||
callVersion.enqueue(new Callback<GiteaVersion>() {
|
callVersion.enqueue(new Callback<GiteaVersion>() {
|
||||||
|
|
||||||
|
@ -52,7 +52,13 @@ import retrofit2.http.Query;
|
|||||||
public interface ApiInterface {
|
public interface ApiInterface {
|
||||||
|
|
||||||
@GET("version") // gitea version API
|
@GET("version") // gitea version API
|
||||||
Call<GiteaVersion> getGiteaVersion();
|
Call<GiteaVersion> getGiteaVersionWithBasic(@Header("Authorization") String authorization);
|
||||||
|
|
||||||
|
@GET("version") // gitea version API
|
||||||
|
Call<GiteaVersion> getGiteaVersionWithOTP(@Header("Authorization") String authorization, @Header("X-Gitea-OTP") int loginOTP);
|
||||||
|
|
||||||
|
@GET("version") // gitea version API
|
||||||
|
Call<GiteaVersion> getGiteaVersionWithToken(@Header("Authorization") String token);
|
||||||
|
|
||||||
@GET("user") // username, full name, email
|
@GET("user") // username, full name, email
|
||||||
Call<UserInfo> getUserInfo(@Header("Authorization") String token);
|
Call<UserInfo> getUserInfo(@Header("Authorization") String token);
|
||||||
|
Loading…
Reference in New Issue
Block a user