This commit is contained in:
parent
7e398059dc
commit
4bb31e9dd3
|
@ -50,7 +50,7 @@
|
|||
<htk-text form="iter" column="value7"/>
|
||||
</p>
|
||||
<p>
|
||||
@<htk-text form="iter" column="id"/>
|
||||
#<htk-text form="iter" column="id"/>
|
||||
</p>
|
||||
<p>
|
||||
<htk-text form="iter" column="image"/>
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
<htk-text form="iter" column="nickname"/>
|
||||
</p>
|
||||
<p>
|
||||
@<htk-text form="iter" column="id"/> -
|
||||
#<htk-text form="iter" column="id"/> -
|
||||
<htk-text form="iter" column="name"/>
|
||||
</p>
|
||||
<div class="clear"/>
|
||||
|
|
|
@ -406,7 +406,7 @@
|
|||
<htk-text form="card" column="subName"/>
|
||||
</p>
|
||||
<p>
|
||||
@<htk-text form="card" column="id"/>
|
||||
#<htk-text form="card" column="id"/>
|
||||
</p>
|
||||
<p>
|
||||
<htk-text form="card" column="stems" format="_%.0d Units"/>
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
<htk-text form="iter" column="landed" format="%D"/>
|
||||
</p>
|
||||
<p>
|
||||
@<htk-text form="iter" column="id"/>
|
||||
#<htk-text form="iter" column="id"/>
|
||||
</p>
|
||||
<p>
|
||||
<htk-text form="iter" column="nickname"/>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<htk-loader class="head" form="ticket">
|
||||
<div>
|
||||
<p class="important ticket-id">
|
||||
@<htk-text column="id" form="ticket"/>
|
||||
#<htk-text column="id" form="ticket"/>
|
||||
</p>
|
||||
<p>
|
||||
<t>Preparation</t> <htk-text form="ticket" column="shipped" format="%D"/>
|
||||
|
@ -151,7 +151,7 @@
|
|||
<htk-text form="iter" column="name"/>
|
||||
</h2>
|
||||
<p>
|
||||
@<htk-text form="iter" column="id"/>
|
||||
#<htk-text form="iter" column="id"/>
|
||||
</p>
|
||||
<p class="amount">
|
||||
<htk-text form="iter" column="quantity"/>
|
||||
|
|
|
@ -128,6 +128,7 @@ module.exports = new Class({
|
|||
* Ends the user supplanting and restores the last login.
|
||||
**/
|
||||
,supplantEnd: function() {
|
||||
this.lbSend('POST', 'Accounts/logout');
|
||||
this.fetchToken();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
</vn-group>
|
||||
<div id="report" class="sheet">
|
||||
<h2>
|
||||
@<htk-text column="id" form="ticket"/>
|
||||
#<htk-text column="id" form="ticket"/>
|
||||
</h2>
|
||||
<div class="header">
|
||||
<div>
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Vn\Web;
|
||||
|
||||
include __DIR__.'/uid.php';
|
||||
|
||||
use Vn\Db;
|
||||
use Vn\Lib\Locale;
|
||||
use Vn\Lib\UserException;
|
||||
|
@ -223,15 +225,45 @@ abstract class Service {
|
|||
return $userDb;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a authentication token for the specified $user.
|
||||
*
|
||||
* @param {string} $user The user name
|
||||
* @param {boolean} $remember Wether to create long live token
|
||||
* @return {string} The generated token
|
||||
*/
|
||||
function createToken($user, $remember = FALSE) {
|
||||
if ($remember)
|
||||
$tokenLife = 2 * WEEK;
|
||||
else
|
||||
$tokenLife = 30 * MIN;
|
||||
|
||||
$token = uid(DEFAULT_TOKEN_LEN);
|
||||
$userId = $this->db->getValue(
|
||||
'SELECT id FROM account.user WHERE `name` = #',
|
||||
[$user]
|
||||
);
|
||||
|
||||
$this->db->query(
|
||||
'INSERT INTO salix.AccessToken
|
||||
SET id = #,
|
||||
ttl = #,
|
||||
created = NOW(),
|
||||
userId = #',
|
||||
[$token, $tokenLife, $userId]
|
||||
);
|
||||
|
||||
return $token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a JWT authentication token for the specified $user.
|
||||
*
|
||||
* @param {string} $user The user name
|
||||
* @param {boolean} $remember Wether to create long live token
|
||||
* @param {boolean} $recover Wether to enable recovery mode on login
|
||||
* @return {string} The JWT generated token
|
||||
*/
|
||||
function createToken($user, $remember = FALSE) {
|
||||
function createJwtToken($user, $remember = FALSE) {
|
||||
if ($remember)
|
||||
$tokenLife = WEEK;
|
||||
else
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace Vn\Web;
|
||||
|
||||
const DEFAULT_TOKEN_LEN = 64;
|
||||
const UIDCHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_';
|
||||
|
||||
function uid($length) {
|
||||
$bytes = bin2hex(random_bytes($length));
|
||||
$r = '';
|
||||
for ($i = 0; $i < $length; $i++)
|
||||
$r .= UIDCHARS[hexdec(substr($bytes, $i * 2, 2)) % 64];
|
||||
return $r;
|
||||
}
|
|
@ -82,7 +82,10 @@ var devConfig = {
|
|||
stats: { chunks: false },
|
||||
proxy: {
|
||||
'/api': 'http://localhost:3000',
|
||||
'/': 'http://localhost/projects/hedera-web'
|
||||
'/': {
|
||||
target: 'http://localhost/projects/hedera-web',
|
||||
bypass: (req) => req.path !== '/' ? req.path : null
|
||||
}
|
||||
}
|
||||
},
|
||||
devtool: 'eval'
|
||||
|
|
Loading…
Reference in New Issue