diff --git a/src/app/login-screen/login-screen.component.html b/src/app/login-screen/login-screen.component.html
index d29b928..32c7deb 100644
--- a/src/app/login-screen/login-screen.component.html
+++ b/src/app/login-screen/login-screen.component.html
@@ -11,8 +11,8 @@
#passwordInput aria-describedby="loginHelp" placeholder="Password">
Login info isn't sent anywhere but Mojang's servers
-
-
+
+
diff --git a/src/app/login-screen/login-screen.component.ts b/src/app/login-screen/login-screen.component.ts
index 3ecb37a..a9d9101 100644
--- a/src/app/login-screen/login-screen.component.ts
+++ b/src/app/login-screen/login-screen.component.ts
@@ -13,8 +13,8 @@ export class LoginScreenComponent implements OnInit {
@ViewChild("passwordInput") passwordInput;
@ViewChild("emailInput") emailInput;
- // @ViewChild("checkbox") checkbox;
- private store: ElectronStore
+ @ViewChild("checkbox") checkbox;
+ private store: ElectronStore;
hasError = false;
errorMessage: string;
private submitting = false;
@@ -27,60 +27,52 @@ export class LoginScreenComponent implements OnInit {
const ElectronStore = require("electron-store");
this.store = new ElectronStore();
this.https = remote.require('https');
- // if (this.store.has("clientToken") && this.store.has("accessToken")) {
- // this.botContainerService.clientToken = this.store.get("clientToken").toString();
- // this.botContainerService.accessToken = this.store.get("accessToken").toString();
- // const data = JSON.stringify({
- // agent: {
- // name: "Minecraft",
- // version: 1
- // },
- // });
- //
- // const options = {
- // hostname: 'authserver.mojang.com',
- // port: 443,
- // path: '/validate',
- // method: 'POST',
- // headers: {
- // 'Content-Type': 'application/json'
- // }
- // }
- //
- // const req = this.https.request(options, (res) => {
- // res.on('data', (data) => {
- // data = JSON.parse((data.toString()));
- //
- // const accessToken = data.accessToken;
- // const clientToken = data.clientToken;
- // this.botContainerService.accessToken = accessToken;
- // this.botContainerService.clientToken = clientToken;
- // this.botContainerService.selectedProfile = data.selectedProfile;
- // this.store.set("clientToken", clientToken);
- // if (this.checkbox.nativeElement.checked) {
- // this.store.set("accessToken", accessToken);
- // this.store.set("username", data.selectedProfile.name);
- // this.store.set("userID", data.selectedProfile.id);
- // }
- // this.ngZone.run(() => {
- // this.router.navigate(['/server-list'])
- // })
- // })
- // });
- //
- //
- // req.write(data, (err) => {
- // if (err !== undefined) {
- // console.info(err);
- // }
- // });
- // req.end()
- // this.botContainerService.selectedProfile = {
- // name: this.store.get("username").toString(),
- // id: this.store.get('userID').toString()
- // };
- // this.router.navigate(["/server-list"])
- // }
+ if (this.store.has("clientToken") && this.store.has("accessToken")) {
+ this.botContainerService.clientToken = this.store.get("clientToken").toString();
+ const data = JSON.stringify({
+ "accessToken": this.store.get("accessToken").toString(),
+ "clientToken": this.botContainerService.clientToken
+ });
+
+ const options = {
+ hostname: 'authserver.mojang.com',
+ port: 443,
+ path: '/refresh',
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json'
+ }
+ };
+
+ const req = this.https.request(options, (res) => {
+ res.on('data', (data) => {
+ data = JSON.parse((data.toString()));
+ console.log(data);
+ if (data.accessToken !== undefined) {
+ console.log(data);
+ this.botContainerService.accessToken = data.accessToken;
+ this.store.set("accessToken", data.accessToken);
+ this.botContainerService.selectedProfile = {
+ name: this.store.get("username").toString(),
+ id: this.store.get('userID').toString()
+ };
+ this.ngZone.run(() => {
+ this.router.navigate(['/server-list'])
+ })
+ }
+
+ })
+ });
+
+
+ req.write(data, (err) => {
+ if (err !== undefined) {
+ console.info(err);
+ }
+ });
+ req.end();
+
+ }
}
@@ -107,7 +99,7 @@ export class LoginScreenComponent implements OnInit {
headers: {
'Content-Type': 'application/json'
}
- }
+ };
const req = this.https.request(options, (res) => {
res.on('data', (data) => {
@@ -122,12 +114,12 @@ export class LoginScreenComponent implements OnInit {
this.botContainerService.accessToken = accessToken;
this.botContainerService.clientToken = clientToken;
this.botContainerService.selectedProfile = data.selectedProfile;
- // if (this.checkbox.nativeElement.checked) {
- // this.store.set("accessToken", accessToken);
- // this.store.set("clientToken", clientToken);
- // this.store.set("username", data.selectedProfile.name);
- // this.store.set("userID", data.selectedProfile.id);
- // }
+ if (this.checkbox.nativeElement.checked) {
+ this.store.set("accessToken", accessToken);
+ this.store.set("clientToken", clientToken);
+ this.store.set("username", data.selectedProfile.name);
+ this.store.set("userID", data.selectedProfile.id);
+ }
this.ngZone.run(() => {
this.router.navigate(['/server-list'])
})
diff --git a/src/app/server-list/server-list.component.ts b/src/app/server-list/server-list.component.ts
index 0d979ed..9156f76 100644
--- a/src/app/server-list/server-list.component.ts
+++ b/src/app/server-list/server-list.component.ts
@@ -103,7 +103,7 @@ export class ServerListComponent implements OnInit {
}
onClickLogoutButton(): void {
- this.store.delete("clientToken");
+ // this.store.delete("clientToken");
this.store.delete("accessToken");
this.store.delete("username");
this.store.delete("userID");