diff --git a/config/app.settings.js b/config/app.settings.js index 6b442c3d..e9926e04 100755 --- a/config/app.settings.js +++ b/config/app.settings.js @@ -17,7 +17,7 @@ export var DevOptions = { default_collapse_sider: ReturnDevOption('default_collapse_sider'), use_dev_server: ReturnDevOption('use_dev_server'), force_show_postactions: ReturnDevOption('force_show_postactions'), - MaxJWTexpire: '1556952', + MaxJWTexpire: 1556952, //1556952 MaxLengthPosts: '512', CurrentBundle: 'light_ng', // In KB diff --git a/src/@ycore/libs/comty_ng/pre.js b/src/@ycore/libs/comty_ng/pre.js index e2cc675c..ddac4979 100755 --- a/src/@ycore/libs/comty_ng/pre.js +++ b/src/@ycore/libs/comty_ng/pre.js @@ -329,24 +329,3 @@ export const get_app_session = { .catch(error => ycore.yconsole.log('error', error)); } } -export function PushUserData(inputIO1, inputIO2) { - var getStoragedToken = Cookies.get('access_token'); - var yCore_GUDEP = ycore.endpoints.update_userData_endpoint; - var urlOBJ = "" + yCore_GUDEP + getStoragedToken; - ycore.yconsole.log('Recived', global, 'sending to ', urlOBJ) - var form = new FormData(); - form.append("server_key", ycore.yConfig.server_key); - form.append(inputIO1, inputIO2); - var settings = { - "url": urlOBJ, - "method": "POST", - "timeout": 0, - "processData": false, - "mimeType": "multipart/form-data", - "contentType": false, - "data": form - }; - jquery.ajax(settings).done(function (response) { - ycore.yconsole.log(response) - }); -} \ No newline at end of file diff --git a/src/@ycore/libs/ycore_sdcp/pre.js b/src/@ycore/libs/ycore_sdcp/pre.js index 34e970b4..bf39b317 100755 --- a/src/@ycore/libs/ycore_sdcp/pre.js +++ b/src/@ycore/libs/ycore_sdcp/pre.js @@ -22,7 +22,6 @@ export const asyncSDCP = { return callback(null, b) }) } catch (err) { - console.log(err); return false } }, @@ -105,7 +104,6 @@ export const CryptSDCP = { }, valid: () => { const a = ycore.asyncSDCP.get() - console.log(a) return a? true : false } @@ -117,6 +115,4 @@ export function SetupApp(){ if (!resourceLoad) { localStorage.setItem('resource_bundle', 'light_ng') } - - } \ No newline at end of file diff --git a/src/@ycore/libs/yulio_id/pre.js b/src/@ycore/libs/yulio_id/pre.js index 95998cf6..dae2c776 100755 --- a/src/@ycore/libs/yulio_id/pre.js +++ b/src/@ycore/libs/yulio_id/pre.js @@ -12,11 +12,7 @@ export function userData(){ return ycore.handlerYIDT.get() } - - function __API__User (payload, sdcp){ - const now = new Date() - now.setDate(now.getDate() + 1) const { UserID, UserToken } = payload const a = ycore.CryptSDCP.atob_parse(sdcp) @@ -31,26 +27,23 @@ function __API__User (payload, sdcp){ dev, is_pro, username, - deadline: ( ycore.DevOptions.SignForNotExpire? null : now.getTime() ) + exp: ycore.DevOptions.SignForNotExpire? 0 : Math.floor(Date.now() / 1000) + (60 * 60), } ycore.handlerYIDT.set(frame, done => { - ycore.RefreshONCE() + done? ycore.RefreshONCE() : null }) } export const handlerYIDT = { set: (value, callback) => { - const ExpireTime = ycore.DevOptions.MaxJWTexpire jwt.sign( value, keys.secretOrKey, - ycore.DevOptions.SignForNotExpire? { expiresIn: '0' } : { expiresIn: ExpireTime }, (err, token) => { err? null : Cookies.set('cid', token) callback(true) } ) - ycore.yconsole.debug(frame) return true }, getRaw: () => { @@ -86,40 +79,43 @@ export const handlerYIDT = { } export function ValidLoginSession(callback){ - const prefix = '[YID Session]'; - let final = false; - let ValidCookiesToken = false; - let ValidSDCP = false; + let validtoken = false; + + const a = Cookies.get('cid'); + if (a) { + const modExp = ycore.DevOptions.SignForNotExpire; + const ad = jwt.decode(a) - let TokenContainer = Cookies.get('cid'); + let notexp = true; // Sets if this is expired (Default is not expired) + let exists = false; // Sets if this exist - if (TokenContainer) { - let TokenContainerDC = jwt.decode(TokenContainer) - if (TokenContainerDC){ - ValidCookiesToken = true - } + ad? (exists = true) : null + + const tokenExp = (ad.exp * 1000) + const tokenExpLocale = new Date(tokenExp).toLocaleString() + const now = new Date().getTime() + + + ycore.yconsole.log(`TOKEN EXP => ${tokenExp} ${modExp? '( Infinite )' : `( ${tokenExpLocale} )` } || NOW => ${now}`) + + + if (modExp == false) { + if(tokenExp < now) { + ycore.yconsole.log('This token is expired !!!') + notexp = false + } + } + if (notexp && exists) { + validtoken = true + } + + } - if (ycore.CryptSDCP.valid()){ - ValidSDCP = true; - } - - if (ValidCookiesToken == true){ - final = true - } - - const finalvalids = { ValidSDCP, ValidCookiesToken, final } - ycore.DevOptions.ShowFunctionsLogs? ( - console.group(`%c ${prefix} `, 'background: #339edf; color: #fff'), - console.log(`Valid SDCP => ${ValidSDCP}`), - console.log(`Valid Token => ${ValidCookiesToken}`), - console.log(`Session is valid => ${final}`), - console.groupEnd() - ) : null if (callback) { - callback(finalvalids) + callback(validtoken) } - return final + return validtoken } export function ValidBackup(){ let ValidBackupToken = false; @@ -134,7 +130,7 @@ export function ValidBackup(){ } export function MakeBackup(){ if (ValidBackup() == false) { - ycore.asyncLocalStorage.setItem('last_backup', Cookies.get('cid')) + localStorage.setItem('last_backup', Cookies.get('cid')) return } } diff --git a/src/components/CustomIcons/index.js b/src/components/CustomIcons/index.js index 1a32f754..2b41965d 100755 --- a/src/components/CustomIcons/index.js +++ b/src/components/CustomIcons/index.js @@ -1,7 +1,7 @@ const VerifiedBadge = () => ( ) const CommonThings = () => () -const SunSVG = () => () -const MoonSVG = () => () +const SunSVG = () => () +const MoonSVG = () => () const RobotOutlined = () => () const CustomIcons = {VerifiedBadge, CommonThings, SunSVG, MoonSVG, RobotOutlined} diff --git a/src/components/Layout/Secondary.less b/src/components/Layout/Secondary.less index d6612f53..5835a7f8 100755 --- a/src/components/Layout/Secondary.less +++ b/src/components/Layout/Secondary.less @@ -27,7 +27,7 @@ top: 25px; display: flex; position: absolute; - z-index: 1003; + z-index: 202; img { border-radius: 15px; width: 40px; @@ -49,7 +49,7 @@ } } .container{ - z-index: 1000; + z-index: 200; background-color: #201F23; color: @DarkMode-color_container !important; border-radius: 32px 0 0 32px; @@ -74,7 +74,7 @@ } .container_2{ - z-index: 1001; + z-index: 201; background-color: #fff; border-radius: 32px 0 0 32px; diff --git a/src/components/MainFeed/index.js b/src/components/MainFeed/index.js index aa615e00..64d1e5a7 100755 --- a/src/components/MainFeed/index.js +++ b/src/components/MainFeed/index.js @@ -120,7 +120,6 @@ class MainFeed extends React.Component {
{invalid? -

Invalid Data

If this error has occurred several times, try restarting the app
diff --git a/src/components/YulioID/index.js b/src/components/YulioID/index.js index 53368dd0..f4b7f737 100755 --- a/src/components/YulioID/index.js +++ b/src/components/YulioID/index.js @@ -1,14 +1,12 @@ import React, { Component } from 'react' -import {GetAuth, InitSDCP, DevOptions, asyncSDCP} from 'ycore'; -import PropTypes from 'prop-types'; import { connect } from 'dva'; import { Form, Icon as LegacyIcon } from '@ant-design/compatible'; -import '@ant-design/compatible/assets/index.css'; -import { Button, Input, Drawer, Collapse } from 'antd'; -import styles from './index.less'; -import formstyle from './formstyle.less' + +import { Button, Input, Drawer } from 'antd'; import * as ycore from 'ycore' +import styles from './index.less'; + const FormItem = Form.Item @connect(({ loading }) => ({ loading })) @@ -23,7 +21,6 @@ class YulioID extends Component { ShowLoading: false, Answered: false, } - this.handleRetry = this.handleRetry.bind(this); } // Handlers & others handleUsername(text) { @@ -32,7 +29,7 @@ class YulioID extends Component { handlePassword(text) { this.setState({ RawPassword: text.target.value }); } - handleRetry() { + handleRetry = () => { this.setState({ShowLoading: false, StateException: false, StateIcon: ''}) } handleEnter = (e) => { @@ -52,7 +49,7 @@ class YulioID extends Component { if (EncUsername && EncPassword){ this.setState({ ShowLoading: true, StateMessage: 'Wait a sec...' }); - if (DevOptions.InfiniteLogin == true) { + if (ycore.DevOptions.InfiniteLogin == true) { ycore.yconsole.log(prefix, 'InfiniteLogin is enabled! Disabled getAuth') } else { @@ -81,9 +78,7 @@ class YulioID extends Component { render() { const { visible } = this.props const { getFieldDecorator } = this.props.form; - const { ShowLoading, StateIcon, StateMessage, StateException } = this.state; - const { Panel } = Collapse; - + const { ShowLoading, StateIcon, StateMessage, StateException } = this.state; return (
@@ -98,11 +93,6 @@ class YulioID extends Component {
YulioID™

Login

- - - - {/* */} -
{ShowLoading ? (
@@ -111,7 +101,7 @@ class YulioID extends Component {



{StateMessage}
- {StateException ?
: null} + {StateException ?
: null}
@@ -189,11 +179,4 @@ class YulioID extends Component { } } -YulioID.propTypes = { - form: PropTypes.object, - dispatch: PropTypes.func, - loading: PropTypes.object, - include: PropTypes.object, -} - export default YulioID diff --git a/src/layouts/BaseLayout.js b/src/layouts/BaseLayout.js index e38d0f82..aefee04b 100755 --- a/src/layouts/BaseLayout.js +++ b/src/layouts/BaseLayout.js @@ -41,7 +41,6 @@ class BaseLayout extends PureComponent { {config.siteName} - {children} ) diff --git a/src/layouts/PrimaryLayout.js b/src/layouts/PrimaryLayout.js index 907a6d8b..410ea57e 100755 --- a/src/layouts/PrimaryLayout.js +++ b/src/layouts/PrimaryLayout.js @@ -25,7 +25,7 @@ class PrimaryLayout extends React.Component { super(props) window.PrimaryComponent = this; this.state = { - collapsed: ycore.DevOptions.default_collapse_sider, + collapsed: (ycore.DevOptions.default_collapse_sider? true : false), isMobile: false, userData: '' } @@ -53,7 +53,6 @@ class PrimaryLayout extends React.Component { store.set('collapsed', !fromStore) } - isDarkMode = () => { const {app} = this.props const { theme } = app @@ -69,7 +68,6 @@ class PrimaryLayout extends React.Component { const { onCollapseChange } = this const { theme } = app - const SiderProps = { theme, userData, diff --git a/src/pages/__m/index.js b/src/pages/__m/index.js index 1ee298ca..42adb32b 100755 --- a/src/pages/__m/index.js +++ b/src/pages/__m/index.js @@ -3,12 +3,10 @@ import React from 'react'; import * as ycore from 'ycore' import * as antd from 'antd' import * as Icons from '@ant-design/icons'; -import $ from 'jquery' -import Icon from '@ant-design/icons' +import jwt from 'jsonwebtoken' import styles from './style.less' -import { GridContent } from '@ant-design/pro-layout'; -import { json } from 'body-parser'; + const UserData = ycore.userData() @@ -40,7 +38,9 @@ export default class __m extends React.Component { }) } handleToken(){ - this.setState({ s_token: ycore.handlerYIDT.get() }) + const a = ycore.handlerYIDT.getRaw() + const b = jwt.decode(a) + this.setState({ s_token: b}) {ycore.ValidLoginSession(res => { this.setState({s_ses: res}) })} @@ -55,7 +55,7 @@ export default class __m extends React.Component { render() { const arrayOfSDCP = Object.entries(UserData).map((e) => ( { [e[0]]: e[1] } )); - const { UserID, UserToken, deadline } = this.state.s_token + const { UserID, UserToken, expiresIn } = this.state.s_token const { ValidSDCP, ValidCookiesToken, final } = this.state.s_ses return (
@@ -73,9 +73,10 @@ export default class __m extends React.Component {

Current Session

+

Raw => {JSON.stringify(this.state.s_token)}

UID => {UserID}

Session Token => {UserToken}

-

Deadline => {deadline}

+

expiresIn => {expiresIn}


ValidSDCP => {JSON.stringify(ValidSDCP)}

ValidCookiesToken => {JSON.stringify(ValidCookiesToken)}