mirror of
https://github.com/kevachat/webapp.git
synced 2025-01-22 20:44:59 +00:00
keep sign method in cookies
This commit is contained in:
parent
bc5307bc2c
commit
ec8fe840ff
4
.env
4
.env
@ -19,7 +19,7 @@ APP_ENV=dev
|
|||||||
APP_SECRET=EDIT_ME
|
APP_SECRET=EDIT_ME
|
||||||
###< symfony/framework-bundle ###
|
###< symfony/framework-bundle ###
|
||||||
|
|
||||||
APP_VERSION=1.7.0
|
APP_VERSION=1.8.0
|
||||||
|
|
||||||
APP_NAME=KevaChat
|
APP_NAME=KevaChat
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ APP_MODERATOR_REMOTE_IP=
|
|||||||
APP_ADD_USER_NAME_REGEX=/^[0-9A-z-]{2,16}$/ui
|
APP_ADD_USER_NAME_REGEX=/^[0-9A-z-]{2,16}$/ui
|
||||||
|
|
||||||
# User name reserved (case insensitive) separated with |
|
# User name reserved (case insensitive) separated with |
|
||||||
APP_ADD_USER_NAME_BLACKLIST=KevaChat|admin|moderator|test
|
APP_ADD_USER_NAME_BLACKLIST=KevaChat|admin|moderator|anon|test
|
||||||
|
|
||||||
# Delay before have ability to create new username again
|
# Delay before have ability to create new username again
|
||||||
APP_ADD_USER_REMOTE_IP_DELAY=86400
|
APP_ADD_USER_REMOTE_IP_DELAY=86400
|
||||||
|
@ -179,13 +179,29 @@ class ModuleController extends AbstractController
|
|||||||
$message = $request->get('message');
|
$message = $request->get('message');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Detect active sign version
|
||||||
|
if (in_array((string) $request->get('sign'), ['anon', 'username']))
|
||||||
|
{
|
||||||
|
$sign = $request->get('sign');
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (in_array((string) $request->cookies->get('KEVACHAT_SIGN'), ['anon', 'username']))
|
||||||
|
{
|
||||||
|
$sign = $request->cookies->get('KEVACHAT_SIGN');
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$sign = 'anon';
|
||||||
|
}
|
||||||
|
|
||||||
return $this->render(
|
return $this->render(
|
||||||
'default/module/post.html.twig',
|
'default/module/post.html.twig',
|
||||||
[
|
[
|
||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'sign' => $request->get('sign'),
|
|
||||||
'error' => $request->get('error'),
|
'error' => $request->get('error'),
|
||||||
|
'sign' => $sign,
|
||||||
'message' => $message,
|
'message' => $message,
|
||||||
'username' => $username,
|
'username' => $username,
|
||||||
'enabled' =>
|
'enabled' =>
|
||||||
|
@ -320,6 +320,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => $this->getParameter('app.maintenance'),
|
'error' => $this->getParameter('app.maintenance'),
|
||||||
'_fragment' => 'latest'
|
'_fragment' => 'latest'
|
||||||
]
|
]
|
||||||
@ -367,6 +368,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => $translator->trans('Namespace not found on this node!'),
|
'error' => $translator->trans('Namespace not found on this node!'),
|
||||||
'_fragment' => 'latest'
|
'_fragment' => 'latest'
|
||||||
]
|
]
|
||||||
@ -396,6 +398,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => $translator->trans('Namespace for read only!'),
|
'error' => $translator->trans('Namespace for read only!'),
|
||||||
'_fragment' => 'latest'
|
'_fragment' => 'latest'
|
||||||
]
|
]
|
||||||
@ -411,6 +414,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => sprintf(
|
'error' => sprintf(
|
||||||
$translator->trans('Access denied for host %s!'),
|
$translator->trans('Access denied for host %s!'),
|
||||||
$request->getClientIp()
|
$request->getClientIp()
|
||||||
@ -429,6 +433,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => sprintf(
|
'error' => sprintf(
|
||||||
$translator->trans('Access restricted for host %s!'),
|
$translator->trans('Access restricted for host %s!'),
|
||||||
$request->getClientIp()
|
$request->getClientIp()
|
||||||
@ -447,6 +452,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => $translator->trans('Message length out of KevaCoin protocol limits'),
|
'error' => $translator->trans('Message length out of KevaCoin protocol limits'),
|
||||||
'_fragment' => 'latest'
|
'_fragment' => 'latest'
|
||||||
]
|
]
|
||||||
@ -462,6 +468,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => sprintf(
|
'error' => sprintf(
|
||||||
$translator->trans('Message does not match node requirements: %s'),
|
$translator->trans('Message does not match node requirements: %s'),
|
||||||
$this->getParameter('app.add.post.value.regex')
|
$this->getParameter('app.add.post.value.regex')
|
||||||
@ -481,6 +488,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => sprintf(
|
'error' => sprintf(
|
||||||
$translator->trans('Please wait %s seconds before post new message!'),
|
$translator->trans('Please wait %s seconds before post new message!'),
|
||||||
(int) $this->getParameter('app.add.post.remote.ip.delay') - (time() - $delay)
|
(int) $this->getParameter('app.add.post.remote.ip.delay') - (time() - $delay)
|
||||||
@ -499,6 +507,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => sprintf(
|
'error' => sprintf(
|
||||||
$translator->trans('Insufficient funds, wallet: %s'),
|
$translator->trans('Insufficient funds, wallet: %s'),
|
||||||
$this->getParameter('app.kevacoin.boost.address')
|
$this->getParameter('app.kevacoin.boost.address')
|
||||||
@ -520,6 +529,16 @@ class RoomController extends AbstractController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Save sign version to cookies
|
||||||
|
if (in_array((string) $request->get('sign'), ['anon', 'username']))
|
||||||
|
{
|
||||||
|
setcookie(
|
||||||
|
'KEVACHAT_SIGN',
|
||||||
|
$request->get('sign'),
|
||||||
|
time() + $this->getParameter('app.session.default.timeout')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// Send message to DHT
|
// Send message to DHT
|
||||||
if (
|
if (
|
||||||
$client->kevaPut(
|
$client->kevaPut(
|
||||||
@ -546,6 +565,7 @@ class RoomController extends AbstractController
|
|||||||
[
|
[
|
||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => null,
|
'error' => null,
|
||||||
'message' => null,
|
'message' => null,
|
||||||
'_fragment' => 'latest'
|
'_fragment' => 'latest'
|
||||||
@ -560,6 +580,7 @@ class RoomController extends AbstractController
|
|||||||
'mode' => $request->get('mode'),
|
'mode' => $request->get('mode'),
|
||||||
'namespace' => $request->get('namespace'),
|
'namespace' => $request->get('namespace'),
|
||||||
'message' => $request->get('message'),
|
'message' => $request->get('message'),
|
||||||
|
'sign' => $request->get('sign'),
|
||||||
'error' => $translator->trans('Internal error! Please feedback'),
|
'error' => $translator->trans('Internal error! Please feedback'),
|
||||||
'_fragment' => 'latest'
|
'_fragment' => 'latest'
|
||||||
]
|
]
|
||||||
|
@ -120,6 +120,7 @@ class UserController extends AbstractController
|
|||||||
|
|
||||||
// Delete cookies
|
// Delete cookies
|
||||||
setcookie('KEVACHAT_SESSION', '', -1);
|
setcookie('KEVACHAT_SESSION', '', -1);
|
||||||
|
setcookie('KEVACHAT_SIGN', '', -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to main page
|
// Redirect to main page
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<output name="error" for="form-post-message">{{ error }}</output>
|
<output name="error" for="form-post-message">{{ error }}</output>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<textarea name="message" id="form-post-message" placeholder="{{ 'enter your message...' | trans }}">{{ message }}</textarea>
|
<textarea name="message" id="form-post-message" placeholder="{{ 'enter your message...' | trans }}">{{ message }}</textarea>
|
||||||
{% if sign == 'anon' or sign != 'username' %}
|
{% if sign == 'anon' or sign == '' %}
|
||||||
<input type="radio" name="sign" value="anon" id="form-post-sign-anon" checked="checked" />
|
<input type="radio" name="sign" value="anon" id="form-post-sign-anon" checked="checked" />
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="radio" name="sign" value="anon" id="form-post-sign-anon" />
|
<input type="radio" name="sign" value="anon" id="form-post-sign-anon" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user