|
@@ -42,41 +42,60 @@ export class AuthGuard implements CanActivate {
|
|
|
'https://audit.hep.com.cn/admin/401?noGoBack=0';
|
|
|
this.router.navigate([this.LoginPage]);
|
|
|
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 {
|
|
|
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(
|
|
|
res?.token || 'r:4d692312d4b08d4120981152e67428f8'
|
|
|
)
|
|
|
.then((user) => resolve(true))
|
|
|
.catch((err) => {
|
|
|
- console.log(err);
|
|
|
+ console.error(err);
|
|
|
window.location.href =
|
|
|
'https://audit.hep.com.cn/admin/401?noGoBack=0';
|
|
|
resolve(false);
|
|
|
});
|
|
|
})
|
|
|
- .catch((error) => {
|
|
|
- console.error('获取token失败:', error);
|
|
|
+ .catch((err) => {
|
|
|
+ console.error('获取token失败:', err);
|
|
|
resolve(false);
|
|
|
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 {
|
|
|
resolve(true);
|
|
|
}
|