mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-09 10:34:17 +00:00
0.1.13-T2
This commit is contained in:
parent
c392515b21
commit
2320d880eb
@ -45,8 +45,5 @@ module.exports = {
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
[`GET ${ApiPrefix}/user/logout`](req, res) {
|
|
||||||
res.clearCookie('token')
|
|
||||||
res.status(200).end()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
3
src/@ycore/libs.js
Normal file
3
src/@ycore/libs.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export * from './libs/comty_ng/pre.js';
|
||||||
|
export * from './libs/yulio_id/pre.js';
|
||||||
|
export * from './libs/ycore_styles/pre.js';
|
146
src/@ycore/libs/comty_ng/pre.js
Normal file
146
src/@ycore/libs/comty_ng/pre.js
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
import * as ycore from 'ycore'
|
||||||
|
var jquery = require("jquery");
|
||||||
|
|
||||||
|
export function FindUser(key, callback){
|
||||||
|
let formdata = new FormData();
|
||||||
|
formdata.append("server_key", ycore.yConfig.server_key);
|
||||||
|
formdata.append("search_key", key);
|
||||||
|
const urlOBJ = `${ycore.endpoints.find_user}${ycore.GetUserToken.decrypted().UserToken}`
|
||||||
|
const settings = {
|
||||||
|
"url": urlOBJ,
|
||||||
|
"method": "POST",
|
||||||
|
"timeout": 10000,
|
||||||
|
"processData": false,
|
||||||
|
"mimeType": "multipart/form-data",
|
||||||
|
"contentType": false,
|
||||||
|
"data": formdata
|
||||||
|
};
|
||||||
|
jquery.ajax(settings)
|
||||||
|
.done(function (response) {
|
||||||
|
return callback(null, response);
|
||||||
|
})
|
||||||
|
.fail(function (response) {
|
||||||
|
const exception = 'API Bad response';
|
||||||
|
return callback(exception, response);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SeachKeywords(key, callback){
|
||||||
|
let formdata = new FormData();
|
||||||
|
formdata.append("server_key", ycore.yConfig.server_key);
|
||||||
|
formdata.append("search_key", key);
|
||||||
|
const urlOBJ = `${ycore.endpoints.search_endpoint}${ycore.GetUserToken.decrypted().UserToken}`
|
||||||
|
const settings = {
|
||||||
|
"url": urlOBJ,
|
||||||
|
"method": "POST",
|
||||||
|
"timeout": 10000,
|
||||||
|
"processData": false,
|
||||||
|
"mimeType": "multipart/form-data",
|
||||||
|
"contentType": false,
|
||||||
|
"data": formdata
|
||||||
|
};
|
||||||
|
jquery.ajax(settings)
|
||||||
|
.done(function (response) {
|
||||||
|
return callback(null, response);
|
||||||
|
})
|
||||||
|
.fail(function (response) {
|
||||||
|
const exception = 'Request Failed';
|
||||||
|
return callback(exception, response);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GetUserPosts(id, callback) {
|
||||||
|
let formdata = new FormData();
|
||||||
|
formdata.append("server_key", ycore.yConfig.server_key);
|
||||||
|
formdata.append("type", "get_user_posts");
|
||||||
|
formdata.append("id", id)
|
||||||
|
const urlOBJ = `${ycore.endpoints.get_user_posts}${ycore.GetUserToken.decrypted().UserToken}`
|
||||||
|
const settings = {
|
||||||
|
"url": urlOBJ,
|
||||||
|
"method": "POST",
|
||||||
|
"timeout": 10000,
|
||||||
|
"processData": false,
|
||||||
|
"mimeType": "multipart/form-data",
|
||||||
|
"contentType": false,
|
||||||
|
"data": formdata
|
||||||
|
};
|
||||||
|
jquery.ajax(settings)
|
||||||
|
.done(function (response) {
|
||||||
|
return callback(null, response);
|
||||||
|
})
|
||||||
|
.fail(function (response) {
|
||||||
|
const exception = 'Request Failed';
|
||||||
|
return callback(exception, response);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GetFeedPosts(callback) {
|
||||||
|
let formdata = new FormData();
|
||||||
|
formdata.append("server_key", ycore.yConfig.server_key);
|
||||||
|
formdata.append("type", "get_news_feed");
|
||||||
|
const requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
body: formdata,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
const objUrl = `${ycore.endpoints.get_userPostFeed}${ycore.GetUserToken.decrypted().UserToken}`
|
||||||
|
console.log(objUrl)
|
||||||
|
fetch(objUrl, requestOptions)
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(result => {
|
||||||
|
return callback( null, result)
|
||||||
|
})
|
||||||
|
.catch(error => console.log('error', error))
|
||||||
|
}
|
||||||
|
|
||||||
|
export const get_app_session = {
|
||||||
|
get_id: (callback) => {
|
||||||
|
const fromSto = sessionStorage.getItem('se_src')
|
||||||
|
if (!fromSto){
|
||||||
|
ycore.DevOptions.ShowFunctionsLogs? console.log("Missing session_id, setting up...") : null
|
||||||
|
let formdata = new FormData();
|
||||||
|
formdata.append("server_key", ycore.yConfig.server_key);
|
||||||
|
formdata.append("type", "get");
|
||||||
|
const requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
body: formdata,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
const uriObj = `${ycore.endpoints.get_sessions}${ycore.GetUserToken.decrypted().UserToken}`
|
||||||
|
notifyProccess()
|
||||||
|
fetch(uriObj, requestOptions)
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(result => {
|
||||||
|
const pre = JSON.stringify(result)
|
||||||
|
const pre2 = JSON.parse(pre)
|
||||||
|
const pre3 = JSON.stringify(JSON.parse(pre2)["data"])
|
||||||
|
const obj = JSON.parse(pre3)["session_id"]
|
||||||
|
return asyncSessionStorage.setItem('se_src', btoa(obj)).then( callback(null, obj) )
|
||||||
|
})
|
||||||
|
.catch(error => console.log('error', error));
|
||||||
|
}
|
||||||
|
ycore.DevOptions.ShowFunctionsLogs? console.log("Returning from storage") : null
|
||||||
|
return callback( null, atob(fromSto) )
|
||||||
|
},
|
||||||
|
raw: (callback) => {
|
||||||
|
const formdata = new FormData();
|
||||||
|
formdata.append("server_key", ycore.yConfig.server_key);
|
||||||
|
formdata.append("type", "get");
|
||||||
|
const requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
body: formdata,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
const uriObj = `${ycore.endpoints.get_sessions}${ycore.GetUserToken.decrypted().UserToken}`
|
||||||
|
fetch(uriObj, requestOptions)
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(result => {
|
||||||
|
const pre = JSON.stringify(result)
|
||||||
|
const parsed = JSON.parse(pre)
|
||||||
|
const obj = JSON.parse(parsed)["data"]
|
||||||
|
ycore.DevOptions.ShowFunctionsLogs? console.log(result, obj) : null
|
||||||
|
return callback(null, obj)
|
||||||
|
})
|
||||||
|
.catch(error => console.log('error', error));
|
||||||
|
}
|
||||||
|
}
|
3
src/@ycore/libs/ycore_styles/pre.js
Normal file
3
src/@ycore/libs/ycore_styles/pre.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function init(){
|
||||||
|
console.log('Init pass!! styles')
|
||||||
|
}
|
3
src/@ycore/libs/yulio_id/pre.js
Normal file
3
src/@ycore/libs/yulio_id/pre.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export function init(){
|
||||||
|
console.log('Init pass!! yulioid')
|
||||||
|
}
|
@ -6,40 +6,21 @@ import {SetControls, CloseControls} from ".././components/Layout/Control"
|
|||||||
import {secretOrKey} from "../../config/keys.js"
|
import {secretOrKey} from "../../config/keys.js"
|
||||||
import * as antd from "antd"
|
import * as antd from "antd"
|
||||||
|
|
||||||
|
import * as lib from'./libs.js'
|
||||||
|
export * from "./libs.js"
|
||||||
|
|
||||||
var react = require("react");
|
var react = require("react");
|
||||||
var package_json = require("../../package.json");
|
var package_json = require("../../package.json");
|
||||||
var jquery = require("jquery");
|
var jquery = require("jquery");
|
||||||
var uifx = require("uifx");
|
|
||||||
var config = require("config");
|
var config = require("config");
|
||||||
var utils = require("utils");
|
var utils = require("utils");
|
||||||
var { router } = require("utils")
|
var { router } = require("utils")
|
||||||
var jwt = require("jsonwebtoken")
|
var jwt = require("jsonwebtoken")
|
||||||
|
|
||||||
export var endpoints = config.Endpoints;
|
export var endpoints = config.Endpoints;
|
||||||
export var DevOptions = config.DevOptions;
|
export var DevOptions = config.DevOptions;
|
||||||
export var yConfig = config.yConfig;
|
export var yConfig = config.yConfig;
|
||||||
|
|
||||||
export const ycore_worker = {
|
|
||||||
ServerVersion: package_json.version,
|
|
||||||
ServerType: package_json.VersionPhase,
|
|
||||||
FXapiProvider: 'https://api.ragestudio.net/RS-YIBTP/lib/uiFXProvider/'
|
|
||||||
};
|
|
||||||
|
|
||||||
export const about_this = {
|
|
||||||
Service_name: package_json.name,
|
|
||||||
Version: package_json.version,
|
|
||||||
Description: package_json.description,
|
|
||||||
Branding: package_json.copyright,
|
|
||||||
Licensing: package_json.license,
|
|
||||||
// Temporaly added from yConfig
|
|
||||||
logotype_uri: 'https://api.ragestudio.net/branding/lib/RDSeries-Branding/rDashboard/BLACK/SVG/T3/rDashboard-FullTextBlack-TM-T3.svg',
|
|
||||||
Phase: package_json.VersionPhase
|
|
||||||
};
|
|
||||||
export const UIFxList = {
|
|
||||||
notifyDefault: (ycore_worker.FXapiProvider + 'NotifyDefault.wav'),
|
|
||||||
notifyWarning: (ycore_worker.FXapiProvider + 'NotifyWarning.wav'),
|
|
||||||
notifySuccess: (ycore_worker.FXapiProvider + 'notifySuccess.wav')
|
|
||||||
};
|
|
||||||
|
|
||||||
export function booleanFix(e){
|
export function booleanFix(e){
|
||||||
if(e == 1){
|
if(e == 1){
|
||||||
@ -47,7 +28,6 @@ export function booleanFix(e){
|
|||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
export const crouter = {
|
export const crouter = {
|
||||||
native: (e) =>{
|
native: (e) =>{
|
||||||
umiRouter.push({
|
umiRouter.push({
|
||||||
@ -59,7 +39,6 @@ export const crouter = {
|
|||||||
router.push(e)
|
router.push(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function notifyError(err){
|
export function notifyError(err){
|
||||||
antd.notification.error({
|
antd.notification.error({
|
||||||
message: 'Wopss',
|
message: 'Wopss',
|
||||||
@ -74,160 +53,6 @@ export function notifyProccess(cust){
|
|||||||
placement: 'bottomLeft'
|
placement: 'bottomLeft'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function FindUser(key, callback){
|
|
||||||
let formdata = new FormData();
|
|
||||||
formdata.append("server_key", yConfig.server_key);
|
|
||||||
formdata.append("search_key", key);
|
|
||||||
const urlOBJ = `${endpoints.find_user}${GetUserToken.decrypted().UserToken}`
|
|
||||||
const settings = {
|
|
||||||
"url": urlOBJ,
|
|
||||||
"method": "POST",
|
|
||||||
"timeout": 10000,
|
|
||||||
"processData": false,
|
|
||||||
"mimeType": "multipart/form-data",
|
|
||||||
"contentType": false,
|
|
||||||
"data": formdata
|
|
||||||
};
|
|
||||||
jquery.ajax(settings)
|
|
||||||
.done(function (response) {
|
|
||||||
return callback(null, response);
|
|
||||||
})
|
|
||||||
.fail(function (response) {
|
|
||||||
const exception = 'API Bad response';
|
|
||||||
return callback(exception, response);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function SeachKeywords(key, callback){
|
|
||||||
let formdata = new FormData();
|
|
||||||
formdata.append("server_key", yConfig.server_key);
|
|
||||||
formdata.append("search_key", key);
|
|
||||||
const urlOBJ = `${endpoints.search_endpoint}${GetUserToken.decrypted().UserToken}`
|
|
||||||
const settings = {
|
|
||||||
"url": urlOBJ,
|
|
||||||
"method": "POST",
|
|
||||||
"timeout": 10000,
|
|
||||||
"processData": false,
|
|
||||||
"mimeType": "multipart/form-data",
|
|
||||||
"contentType": false,
|
|
||||||
"data": formdata
|
|
||||||
};
|
|
||||||
jquery.ajax(settings)
|
|
||||||
.done(function (response) {
|
|
||||||
return callback(null, response);
|
|
||||||
})
|
|
||||||
.fail(function (response) {
|
|
||||||
const exception = 'Request Failed';
|
|
||||||
return callback(exception, response);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
export function GetUserPosts(id, callback) {
|
|
||||||
let formdata = new FormData();
|
|
||||||
formdata.append("server_key", yConfig.server_key);
|
|
||||||
formdata.append("type", "get_user_posts");
|
|
||||||
formdata.append("id", id)
|
|
||||||
const urlOBJ = `${endpoints.get_user_posts}${GetUserToken.decrypted().UserToken}`
|
|
||||||
|
|
||||||
const settings = {
|
|
||||||
"url": urlOBJ,
|
|
||||||
"method": "POST",
|
|
||||||
"timeout": 10000,
|
|
||||||
"processData": false,
|
|
||||||
"mimeType": "multipart/form-data",
|
|
||||||
"contentType": false,
|
|
||||||
"data": formdata
|
|
||||||
};
|
|
||||||
jquery.ajax(settings)
|
|
||||||
.done(function (response) {
|
|
||||||
return callback(null, response);
|
|
||||||
})
|
|
||||||
.fail(function (response) {
|
|
||||||
const exception = 'Request Failed';
|
|
||||||
return callback(exception, response);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function GetFeedPosts(callback) {
|
|
||||||
let formdata = new FormData();
|
|
||||||
formdata.append("server_key", yConfig.server_key);
|
|
||||||
formdata.append("type", "get_news_feed");
|
|
||||||
|
|
||||||
const requestOptions = {
|
|
||||||
method: 'POST',
|
|
||||||
body: formdata,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
const objUrl = `${endpoints.get_userPostFeed}${GetUserToken.decrypted().UserToken}`
|
|
||||||
console.log(objUrl)
|
|
||||||
fetch(objUrl, requestOptions)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(result => {
|
|
||||||
return callback( null, result)
|
|
||||||
})
|
|
||||||
.catch(error => console.log('error', error));
|
|
||||||
}
|
|
||||||
|
|
||||||
export const get_app_session = {
|
|
||||||
get_id: (callback) => {
|
|
||||||
const fromSto = sessionStorage.getItem('se_src')
|
|
||||||
if (!fromSto){
|
|
||||||
DevOptions.ShowFunctionsLogs? console.log("Missing session_id, setting up...") : null
|
|
||||||
let formdata = new FormData();
|
|
||||||
formdata.append("server_key", yConfig.server_key);
|
|
||||||
formdata.append("type", "get");
|
|
||||||
const requestOptions = {
|
|
||||||
method: 'POST',
|
|
||||||
body: formdata,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
const uriObj = `${endpoints.get_sessions}${GetUserToken.decrypted().UserToken}`
|
|
||||||
notifyProccess()
|
|
||||||
fetch(uriObj, requestOptions)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(result => {
|
|
||||||
const pre = JSON.stringify(result)
|
|
||||||
const pre2 = JSON.parse(pre)
|
|
||||||
const pre3 = JSON.stringify(JSON.parse(pre2)["data"])
|
|
||||||
|
|
||||||
const obj = JSON.parse(pre3)["session_id"]
|
|
||||||
|
|
||||||
return asyncSessionStorage.setItem('se_src', btoa(obj)).then( callback(null, obj) )
|
|
||||||
|
|
||||||
})
|
|
||||||
.catch(error => console.log('error', error));
|
|
||||||
}
|
|
||||||
DevOptions.ShowFunctionsLogs? console.log("Returning from storage") : null
|
|
||||||
return callback( null, atob(fromSto) )
|
|
||||||
},
|
|
||||||
raw: (callback) => {
|
|
||||||
const formdata = new FormData();
|
|
||||||
formdata.append("server_key", yConfig.server_key);
|
|
||||||
formdata.append("type", "get");
|
|
||||||
|
|
||||||
const requestOptions = {
|
|
||||||
method: 'POST',
|
|
||||||
body: formdata,
|
|
||||||
redirect: 'follow'
|
|
||||||
};
|
|
||||||
const uriObj = `${endpoints.get_sessions}${GetUserToken.decrypted().UserToken}`
|
|
||||||
fetch(uriObj, requestOptions)
|
|
||||||
.then(response => response.text())
|
|
||||||
.then(result => {
|
|
||||||
const pre = JSON.stringify(result)
|
|
||||||
const parsed = JSON.parse(pre)
|
|
||||||
const obj = JSON.parse(parsed)["data"]
|
|
||||||
DevOptions.ShowFunctionsLogs? console.log(result, obj) : null
|
|
||||||
return callback(null, obj)
|
|
||||||
})
|
|
||||||
.catch(error => console.log('error', error));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
export function InitSocket(id, params){
|
export function InitSocket(id, params){
|
||||||
console.log('Starting socket with _id: ', id)
|
console.log('Starting socket with _id: ', id)
|
||||||
const defaultParams = {fullscreen: true, collapse: true}
|
const defaultParams = {fullscreen: true, collapse: true}
|
||||||
@ -297,9 +122,6 @@ export const asyncSDCP = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
export const ControlBar = {
|
export const ControlBar = {
|
||||||
setCreate: (e) =>{
|
|
||||||
|
|
||||||
},
|
|
||||||
set: (e) => {
|
set: (e) => {
|
||||||
SetControls(e)
|
SetControls(e)
|
||||||
},
|
},
|
||||||
@ -311,14 +133,12 @@ export function SyncSocketAccount(title, socket, logo) {
|
|||||||
DevOptions.ShowFunctionsLogs? console.log('Initialising auth for ', title) : null
|
DevOptions.ShowFunctionsLogs? console.log('Initialising auth for ', title) : null
|
||||||
const signkey = secretOrKey;
|
const signkey = secretOrKey;
|
||||||
const ExpireTime = '300';
|
const ExpireTime = '300';
|
||||||
|
|
||||||
const key = {title, socket, logo}
|
const key = {title, socket, logo}
|
||||||
const ckey = jwt.sign(
|
const ckey = jwt.sign(
|
||||||
key,
|
key,
|
||||||
signkey,
|
signkey,
|
||||||
{ expiresIn: ExpireTime },
|
{ expiresIn: ExpireTime },
|
||||||
)
|
)
|
||||||
|
|
||||||
DevOptions.ShowFunctionsLogs? console.log(key, jwt.decode(ckey)) : null
|
DevOptions.ShowFunctionsLogs? console.log(key, jwt.decode(ckey)) : null
|
||||||
asyncLocalStorage.setItem('AUTHRES', ckey).then(
|
asyncLocalStorage.setItem('AUTHRES', ckey).then(
|
||||||
window.open('/ec/authorize', title, "height=589,width=511")
|
window.open('/ec/authorize', title, "height=589,width=511")
|
||||||
@ -332,8 +152,6 @@ export function GetAuthSocket(sc, values) {
|
|||||||
}
|
}
|
||||||
const PayloadData = new FormData();
|
const PayloadData = new FormData();
|
||||||
PayloadData.append("server_key", yConfig.server_key);
|
PayloadData.append("server_key", yConfig.server_key);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
export function ValidLoginSession(){
|
export function ValidLoginSession(){
|
||||||
const prefix = '[YID Session]';
|
const prefix = '[YID Session]';
|
||||||
@ -365,7 +183,6 @@ export function ValidLoginSession(){
|
|||||||
console.groupEnd()
|
console.groupEnd()
|
||||||
) : null
|
) : null
|
||||||
return final
|
return final
|
||||||
|
|
||||||
}
|
}
|
||||||
export function ValidBackup(){
|
export function ValidBackup(){
|
||||||
const prefix = '[YID SessionState]';
|
const prefix = '[YID SessionState]';
|
||||||
@ -385,11 +202,10 @@ export function MakeBackup(){
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function LogoutCall(){
|
export function LogoutCall(){
|
||||||
const prefix = ('[YID Session] ')
|
const prefix = ('[YID Session] ')
|
||||||
console.log('Logout Called !')
|
console.log('Logout Called !')
|
||||||
let DecodedToken = GetUserToken.decrypted()
|
let DecodedToken = GetUserToken.decrypted().userToken
|
||||||
if (DecodedToken == false) {
|
if (DecodedToken == false) {
|
||||||
antd.notification.open({
|
antd.notification.open({
|
||||||
placement: 'topLeft',
|
placement: 'topLeft',
|
||||||
@ -400,8 +216,8 @@ export function LogoutCall(){
|
|||||||
router.push({pathname: '/login',})
|
router.push({pathname: '/login',})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const urlOBJ = "" + endpoints.removeToken + DecodedToken.UserToken;
|
const urlOBJ = "" + endpoints.removeToken + DecodedToken;
|
||||||
DevOptions.ShowFunctionsLogs? console.log(prefix, ' Login out with token => ', DecodedToken.UserToken, urlOBJ) : null
|
DevOptions.ShowFunctionsLogs? console.log(prefix, ' Login out with token => ', DecodedToken, urlOBJ) : null
|
||||||
const form = new FormData();
|
const form = new FormData();
|
||||||
form.append("server_key", yConfig.server_key);
|
form.append("server_key", yConfig.server_key);
|
||||||
const settings = {
|
const settings = {
|
||||||
@ -414,16 +230,26 @@ export function LogoutCall(){
|
|||||||
"data": form
|
"data": form
|
||||||
};
|
};
|
||||||
jquery.ajax(settings)
|
jquery.ajax(settings)
|
||||||
.done( (response) => {
|
.done((response) => {
|
||||||
const url = '/api/v1/user/logout'
|
const api_state = JSON.parse(response)['api_status']
|
||||||
const method = 'GET'
|
console.log(`Exit with => ${api_state}`)
|
||||||
utils.request({method, url})
|
if (api_state == '404') {
|
||||||
|
antd.notification.open({
|
||||||
|
placement: 'topLeft',
|
||||||
|
message: 'Unexpectedly failed logout in YulioID™ ',
|
||||||
|
description: 'It seems that your token has been removed unexpectedly and could not log out from YulioID ',
|
||||||
|
icon: <antd.Icon type="warning" style={{ color: 'orange' }} />
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("Successful logout in YulioID™", response, urlOBJ)
|
||||||
|
}
|
||||||
|
// Runtime after dispatch API
|
||||||
sessionStorage.clear()
|
sessionStorage.clear()
|
||||||
console.log("Successful logout in YulioID™", response, urlOBJ)
|
Cookies.remove('token')
|
||||||
router.push({pathname: '/login',})
|
router.push({pathname: '/login',})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function GetAuth(EncUsername, EncPassword, callback) {
|
export function GetAuth(EncUsername, EncPassword, callback) {
|
||||||
const prefix = '[Auth Server]:';
|
const prefix = '[Auth Server]:';
|
||||||
if (!EncUsername || !EncPassword) {
|
if (!EncUsername || !EncPassword) {
|
||||||
@ -454,7 +280,7 @@ export function GetAuth(EncUsername, EncPassword, callback) {
|
|||||||
.fail(function (response) {
|
.fail(function (response) {
|
||||||
const exception = new Error("Server failed response . . . :( ");
|
const exception = new Error("Server failed response . . . :( ");
|
||||||
return callback(exception, response);
|
return callback(exception, response);
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
export const GetUserToken = {
|
export const GetUserToken = {
|
||||||
decrypted: function () {
|
decrypted: function () {
|
||||||
@ -477,8 +303,7 @@ export const GetUserToken = {
|
|||||||
raw: function () {
|
raw: function () {
|
||||||
return Cookies.get('token') || localStorage.getItem('last_backup');
|
return Cookies.get('token') || localStorage.getItem('last_backup');
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
export function GetUserData (values, customPayload, callback) {
|
export function GetUserData (values, customPayload, callback) {
|
||||||
const prefix = '[YID SDCP]';
|
const prefix = '[YID SDCP]';
|
||||||
const request = 'user_data' || customPayload;
|
const request = 'user_data' || customPayload;
|
||||||
@ -504,7 +329,7 @@ export function GetUserData (values, customPayload, callback) {
|
|||||||
"mimeType": "multipart/form-data",
|
"mimeType": "multipart/form-data",
|
||||||
"contentType": false,
|
"contentType": false,
|
||||||
"data": ApiPayload
|
"data": ApiPayload
|
||||||
};
|
}
|
||||||
jquery.ajax(settings)
|
jquery.ajax(settings)
|
||||||
.done(
|
.done(
|
||||||
function (response) {
|
function (response) {
|
||||||
@ -521,7 +346,7 @@ export function GetUserData (values, customPayload, callback) {
|
|||||||
callback( null )
|
callback( null )
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
export function InitSDCP(values, done) {
|
export function InitSDCP(values, done) {
|
||||||
const prefix = '[InitSDCP]';
|
const prefix = '[InitSDCP]';
|
||||||
@ -541,7 +366,7 @@ export function InitSDCP(values, done) {
|
|||||||
asyncSDCP.setSDCP(Ensamblator).then(() => {
|
asyncSDCP.setSDCP(Ensamblator).then(() => {
|
||||||
DevOptions.ShowFunctionsLogs? console.log(prefix, ' SDCP Setup done') : null
|
DevOptions.ShowFunctionsLogs? console.log(prefix, ' SDCP Setup done') : null
|
||||||
return done(true)
|
return done(true)
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@ -560,7 +385,6 @@ export function UpdateSDCP() {
|
|||||||
}else{
|
}else{
|
||||||
DevOptions.ShowFunctionsLogs? console.log(prefix, 'SDCP Update detected ! => ', n) : null
|
DevOptions.ShowFunctionsLogs? console.log(prefix, 'SDCP Update detected ! => ', n) : null
|
||||||
asyncSDCP.setSDCP(e2)
|
asyncSDCP.setSDCP(e2)
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -584,7 +408,6 @@ export function SDCP() {
|
|||||||
router.push({pathname: '/login',})
|
router.push({pathname: '/login',})
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export function PushUserData(inputIO1, inputIO2) {
|
export function PushUserData(inputIO1, inputIO2) {
|
||||||
@ -614,10 +437,8 @@ export function GetGlobalMarketplaceSource() {
|
|||||||
let TokenContainer = Cookies.get('token') || localStorage.getItem('last_backup');
|
let TokenContainer = Cookies.get('token') || localStorage.getItem('last_backup');
|
||||||
let DecodedToken = jwt.decode(TokenContainer)
|
let DecodedToken = jwt.decode(TokenContainer)
|
||||||
let usertoken = DecodedToken.UserToken;
|
let usertoken = DecodedToken.UserToken;
|
||||||
|
|
||||||
const uri = endpoints.get_marketplace_global;
|
const uri = endpoints.get_marketplace_global;
|
||||||
const urlOBJ = "" + uri + usertoken;
|
const urlOBJ = "" + uri + usertoken;
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
const response = await axios({
|
const response = await axios({
|
||||||
url: urlOBJ,
|
url: urlOBJ,
|
||||||
@ -626,14 +447,8 @@ export function GetGlobalMarketplaceSource() {
|
|||||||
global = response.data
|
global = response.data
|
||||||
console.log(response.data, global)
|
console.log(response.data, global)
|
||||||
return {global};
|
return {global};
|
||||||
|
|
||||||
})()
|
})()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//* *//
|
|
||||||
//* Helpers *//
|
|
||||||
//* *//
|
|
||||||
export function DetectNoNStableBuild(e1) {
|
export function DetectNoNStableBuild(e1) {
|
||||||
switch (e1) {
|
switch (e1) {
|
||||||
case 'TagComponent':
|
case 'TagComponent':
|
||||||
@ -660,40 +475,6 @@ export function DetectNoNStableBuild(e1) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getRandomBG(imgAr) {
|
|
||||||
var path = 'https://api.ragestudio.net/RS-YIBTP/lib/statics/heros/';
|
|
||||||
var num = Math.floor(Math.random() * imgAr.length);
|
|
||||||
var img = imgAr[num];
|
|
||||||
var out = (path + img);
|
|
||||||
return (out);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function UIFxPY(value, customVLM) {
|
|
||||||
// UIFX Player v1.4A
|
|
||||||
var dispatcher = value;
|
|
||||||
var userVLM = localStorage.getItem('UIfx');
|
|
||||||
var VLM;
|
|
||||||
var conv = parseFloat(userVLM);
|
|
||||||
if (conv < 1.1) {
|
|
||||||
if (conv == 1) {
|
|
||||||
VLM = 1.0;
|
|
||||||
}
|
|
||||||
if (conv == 0) {
|
|
||||||
VLM = 0.0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
VLM = conv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
VLM = 1.0;
|
|
||||||
}
|
|
||||||
var beep = new uifx({ asset: dispatcher });
|
|
||||||
DevOptions.ShowFunctionsLogs? console.log('The Volume of UIFX is on ', VLM || customVLM, '/ User set on', conv) : null
|
|
||||||
beep.setVolume(VLM || customVLM).play();
|
|
||||||
}
|
|
||||||
|
|
||||||
export function RefreshONCE(){
|
export function RefreshONCE(){
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,8 @@ import { router } from 'utils'
|
|||||||
import { stringify } from 'qs'
|
import { stringify } from 'qs'
|
||||||
import store from 'store'
|
import store from 'store'
|
||||||
import { queryLayout, pathMatchRegexp } from 'utils'
|
import { queryLayout, pathMatchRegexp } from 'utils'
|
||||||
import { CANCEL_REQUEST_MESSAGE } from 'utils/constant'
|
|
||||||
import api from 'api'
|
import api from 'api'
|
||||||
import config from 'config'
|
import config from 'config'
|
||||||
import Cookies from 'js-cookie'
|
|
||||||
import * as ycore from 'ycore'
|
import * as ycore from 'ycore'
|
||||||
import jwt from 'jsonwebtoken'
|
import jwt from 'jsonwebtoken'
|
||||||
const { queryRouteList, logoutUser, queryUserInfo } = api
|
const { queryRouteList, logoutUser, queryUserInfo } = api
|
||||||
@ -52,7 +50,7 @@ export default {
|
|||||||
const { cancelRequest = new Map() } = window
|
const { cancelRequest = new Map() } = window
|
||||||
cancelRequest.forEach((value, key) => {
|
cancelRequest.forEach((value, key) => {
|
||||||
if (value.pathname !== window.location.pathname) {
|
if (value.pathname !== window.location.pathname) {
|
||||||
value.cancel(CANCEL_REQUEST_MESSAGE)
|
value.cancel('Canceling...')
|
||||||
cancelRequest.delete(key)
|
cancelRequest.delete(key)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -71,28 +69,25 @@ export default {
|
|||||||
|
|
||||||
const valid = ycore.ValidLoginSession();
|
const valid = ycore.ValidLoginSession();
|
||||||
const validBackup = ycore.ValidBackup();
|
const validBackup = ycore.ValidBackup();
|
||||||
if ( valid == true) {
|
if (valid == true) {
|
||||||
if (pathMatchRegexp(['/', '/login'], window.location.pathname)) {
|
if (pathMatchRegexp(['/', '/login'], window.location.pathname)) {
|
||||||
router.push({pathname: '/main',})
|
router.push({pathname: '/main',})
|
||||||
ycore.RefreshONCE()
|
ycore.RefreshONCE()
|
||||||
}else{
|
}
|
||||||
|
// Runtime
|
||||||
ycore.MakeBackup()
|
ycore.MakeBackup()
|
||||||
ycore.UpdateSDCP()
|
ycore.UpdateSDCP()
|
||||||
}
|
|
||||||
} else if (queryLayout(config.layouts, locationPathname) !== 'public') {
|
}
|
||||||
|
else if(!pathMatchRegexp(['/', '/login'], window.location.pathname)) {
|
||||||
if (validBackup == true) {
|
if (validBackup == true) {
|
||||||
ycore.LogoutCall()
|
ycore.LogoutCall()
|
||||||
return
|
}
|
||||||
}else if (ycore.GetUserToken == false){
|
else{
|
||||||
notification.open({
|
router.push({pathname: '/login',})
|
||||||
placement: 'topLeft',
|
ycore.RefreshONCE()
|
||||||
message: 'Unexpectedly failed logout in YulioID™ ',
|
|
||||||
description: 'It seems that your token has been removed unexpectedly and could not log out from YulioID ',
|
|
||||||
icon: <Icon type="warning" style={{ color: 'orange' }} />
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
router.push({pathname: '/login',})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -1,36 +1,14 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { getRandomBG } from 'ycore';
|
|
||||||
import { YulioID } from 'components';
|
import { YulioID } from 'components';
|
||||||
let imgRend;
|
|
||||||
|
|
||||||
class Login extends Component {
|
class Login extends Component {
|
||||||
constructor(props){
|
|
||||||
super(props)
|
|
||||||
this.state = {
|
|
||||||
// Setting default method
|
|
||||||
type: 'stable'
|
|
||||||
}
|
|
||||||
this.changeMethod = this.changeMethod.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount(){
|
|
||||||
// INIT
|
|
||||||
var arrayBg = new Array();
|
|
||||||
arrayBg[0] = "bg-1-an";
|
|
||||||
arrayBg[1] = "bg-2-an";
|
|
||||||
arrayBg[2] = "bg-3-an";
|
|
||||||
arrayBg[3] = "bg-4-an";
|
|
||||||
arrayBg[4] = "bg-5-an";
|
|
||||||
arrayBg[5] = "bg-6-an";
|
|
||||||
arrayBg[6] = "bg-1-an";
|
|
||||||
imgRend = getRandomBG(arrayBg)
|
|
||||||
}
|
|
||||||
|
|
||||||
changeMethod() {
|
|
||||||
this.setState({type: 'stable'})
|
|
||||||
}
|
|
||||||
render() {
|
render() {
|
||||||
const { type } = this.state;
|
|
||||||
return (
|
return (
|
||||||
<YulioID include={<div>Using stable</div>} />
|
<YulioID include={<div>Using stable</div>} />
|
||||||
)
|
)
|
||||||
|
@ -57,6 +57,7 @@ class Main extends React.Component {
|
|||||||
<antd.Skeleton avatar paragraph={{ rows: 4 }} active />
|
<antd.Skeleton avatar paragraph={{ rows: 4 }} active />
|
||||||
</antd.Card> :
|
</antd.Card> :
|
||||||
<div id="PostsWrapper" className={styles.PostsWrapper}>
|
<div id="PostsWrapper" className={styles.PostsWrapper}>
|
||||||
|
|
||||||
<antd.BackTop target={() => document.getElementById("PostsWrapper") } />
|
<antd.BackTop target={() => document.getElementById("PostsWrapper") } />
|
||||||
{this.renderFeedPosts()}
|
{this.renderFeedPosts()}
|
||||||
</div>}
|
</div>}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
// ** Deprecated Roles ** //
|
|
||||||
// export const ROLE_TYPE = {
|
|
||||||
// ADMIN: 'admin',
|
|
||||||
// DEFAULT: 'guest',
|
|
||||||
// DEVELOPER: 'developer',
|
|
||||||
// }
|
|
||||||
|
|
||||||
export const CANCEL_REQUEST_MESSAGE = 'cancel request';
|
|
@ -1,20 +0,0 @@
|
|||||||
import { pathMatchRegexp } from './index'
|
|
||||||
import pathToRegexp from 'path-to-regexp'
|
|
||||||
|
|
||||||
describe('test pathMatchRegexp', () => {
|
|
||||||
it('get right', () => {
|
|
||||||
expect(pathMatchRegexp('/user', '/zh/user')).toEqual(
|
|
||||||
pathToRegexp('/user').exec('/user')
|
|
||||||
)
|
|
||||||
expect(pathMatchRegexp('/user', '/user')).toEqual(
|
|
||||||
pathToRegexp('/user').exec('/user')
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(pathMatchRegexp('/user/:id', '/zh/user/1')).toEqual(
|
|
||||||
pathToRegexp('/user/:id').exec('/user/1')
|
|
||||||
)
|
|
||||||
expect(pathMatchRegexp('/user/:id', '/user/1')).toEqual(
|
|
||||||
pathToRegexp('/user/:id').exec('/user/1')
|
|
||||||
)
|
|
||||||
})
|
|
||||||
})
|
|
@ -2,7 +2,6 @@ import axios from 'axios'
|
|||||||
import { cloneDeep, isEmpty } from 'lodash'
|
import { cloneDeep, isEmpty } from 'lodash'
|
||||||
import pathToRegexp from 'path-to-regexp'
|
import pathToRegexp from 'path-to-regexp'
|
||||||
import { message } from 'antd'
|
import { message } from 'antd'
|
||||||
import { CANCEL_REQUEST_MESSAGE } from 'utils/constant'
|
|
||||||
import qs from 'qs'
|
import qs from 'qs'
|
||||||
|
|
||||||
const { CancelToken } = axios
|
const { CancelToken } = axios
|
||||||
@ -69,7 +68,7 @@ export default function request(options) {
|
|||||||
.catch(error => {
|
.catch(error => {
|
||||||
const { response, message } = error
|
const { response, message } = error
|
||||||
|
|
||||||
if (String(message) === CANCEL_REQUEST_MESSAGE) {
|
if (String(message) === 'Canceling...') {
|
||||||
return {
|
return {
|
||||||
success: false,
|
success: false,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user