|
@@ -43,14 +43,24 @@ export function defineTbookISBN(){
|
|
|
});
|
|
|
Parse.Cloud.define("reviewToken", async (request) => {
|
|
|
let refer = request.headers["referer"] || request.headers["referered"];
|
|
|
+ console.log(refer)
|
|
|
// 检查referer来源
|
|
|
- if (refer && refer.indexOf('https://145.tbook.com.cn') == 0) {
|
|
|
- Parse.User.logIn('145review', 'review-textbook145').then((user) => {
|
|
|
- // console.log(user?.get('sessionToken'));
|
|
|
- return {token: user?.get('sessionToken')}
|
|
|
- }).catch(err=>{
|
|
|
+ if (refer?.indexOf('https://145.tbook.com.cn') > -1) {
|
|
|
+ let user
|
|
|
+ try{
|
|
|
+ user = await Parse.User.logIn('145review', 'review-textbook145')
|
|
|
+ }catch(err1){}
|
|
|
+ try{
|
|
|
+ if(!user?.id) user = await Parse.User.signUp("145review",'review-textbook145')
|
|
|
+ }catch(err2){}
|
|
|
+
|
|
|
+ if(user?.id){
|
|
|
+ console.log(user?.id)
|
|
|
+ console.log(user?.getSessionToken())
|
|
|
+ return {token: user?.getSessionToken()}
|
|
|
+ }
|
|
|
throw new Parse.Error(404,"invalid user")
|
|
|
- })
|
|
|
+
|
|
|
}else{
|
|
|
throw new Parse.Error(404,"not found referer")
|
|
|
}
|