|
@@ -42,41 +42,60 @@ export class AuthGuard implements CanActivate {
|
|
'https://audit.hep.com.cn/admin/401?noGoBack=0';
|
|
'https://audit.hep.com.cn/admin/401?noGoBack=0';
|
|
this.router.navigate([this.LoginPage]);
|
|
this.router.navigate([this.LoginPage]);
|
|
resolve(false);
|
|
resolve(false);
|
|
- // Parse.User.logIn('145review', 'review-textbook145').then((user) => {
|
|
|
|
- // resolve(true);
|
|
|
|
|
|
+ // fetch('https://145.tbook.com.cn/api/textbook/review/token', {
|
|
|
|
+ // method: 'POST',
|
|
|
|
+ // headers: {
|
|
|
|
+ // 'Content-Type': 'application/json',
|
|
|
|
+ // },
|
|
// })
|
|
// })
|
|
- // Parse.User.become('r:4d692312d4b08d4120981152e67428f8')
|
|
|
|
- // .then((user) => resolve(true))
|
|
|
|
- // .catch((err) => {
|
|
|
|
- // resolve(false);
|
|
|
|
- // this.router.navigate([this.LoginPage]);
|
|
|
|
|
|
+ // .then((response) => response.json())
|
|
|
|
+ // .then(async (res) => {
|
|
|
|
+ // console.log(res);
|
|
// });
|
|
// });
|
|
} else {
|
|
} else {
|
|
if (!Parse.User.current()?.id) {
|
|
if (!Parse.User.current()?.id) {
|
|
- fetch('https://145.tbook.com.cn/api/textbook/review/token', {
|
|
|
|
- method: 'POST',
|
|
|
|
- headers: {
|
|
|
|
- 'Content-Type': 'application/json',
|
|
|
|
- },
|
|
|
|
- })
|
|
|
|
- .then((response) => response.json())
|
|
|
|
- .then(async (res) => {
|
|
|
|
|
|
+ Parse.Cloud.run('reviewToken')
|
|
|
|
+ .then((res) => {
|
|
Parse.User.become(
|
|
Parse.User.become(
|
|
res?.token || 'r:4d692312d4b08d4120981152e67428f8'
|
|
res?.token || 'r:4d692312d4b08d4120981152e67428f8'
|
|
)
|
|
)
|
|
.then((user) => resolve(true))
|
|
.then((user) => resolve(true))
|
|
.catch((err) => {
|
|
.catch((err) => {
|
|
- console.log(err);
|
|
|
|
|
|
+ console.error(err);
|
|
window.location.href =
|
|
window.location.href =
|
|
'https://audit.hep.com.cn/admin/401?noGoBack=0';
|
|
'https://audit.hep.com.cn/admin/401?noGoBack=0';
|
|
resolve(false);
|
|
resolve(false);
|
|
});
|
|
});
|
|
})
|
|
})
|
|
- .catch((error) => {
|
|
|
|
- console.error('获取token失败:', error);
|
|
|
|
|
|
+ .catch((err) => {
|
|
|
|
+ console.error('获取token失败:', err);
|
|
resolve(false);
|
|
resolve(false);
|
|
this.router.navigate([this.LoginPage]);
|
|
this.router.navigate([this.LoginPage]);
|
|
});
|
|
});
|
|
|
|
+ // fetch('https://145.tbook.com.cn/api/textbook/review/token', {
|
|
|
|
+ // method: 'POST',
|
|
|
|
+ // headers: {
|
|
|
|
+ // 'Content-Type': 'application/json',
|
|
|
|
+ // },
|
|
|
|
+ // })
|
|
|
|
+ // .then((response) => response.json())
|
|
|
|
+ // .then(async (res) => {
|
|
|
|
+ // Parse.User.become(
|
|
|
|
+ // res?.token || 'r:4d692312d4b08d4120981152e67428f8'
|
|
|
|
+ // )
|
|
|
|
+ // .then((user) => resolve(true))
|
|
|
|
+ // .catch((err) => {
|
|
|
|
+ // console.log(err);
|
|
|
|
+ // window.location.href =
|
|
|
|
+ // 'https://audit.hep.com.cn/admin/401?noGoBack=0';
|
|
|
|
+ // resolve(false);
|
|
|
|
+ // });
|
|
|
|
+ // })
|
|
|
|
+ // .catch((error) => {
|
|
|
|
+ // console.error('获取token失败:', error);
|
|
|
|
+ // resolve(false);
|
|
|
|
+ // this.router.navigate([this.LoginPage]);
|
|
|
|
+ // });
|
|
} else {
|
|
} else {
|
|
resolve(true);
|
|
resolve(true);
|
|
}
|
|
}
|