added login failed message (remains register message); installed flood_control contrib module

This commit is contained in:
Bachir Soussi Chiadmi 2021-01-27 22:49:52 +01:00
parent 584c4cc5d2
commit e65dfeb5b5
15 changed files with 235 additions and 30 deletions

View File

@ -46,6 +46,7 @@
"drupal/field_group": "3.x-dev@dev",
"drupal/field_permissions": "^1.0",
"drupal/flag_lists": "^4.0@beta",
"drupal/flood_control": "^2.1",
"drupal/genpass": "^1.x-dev",
"drupal/graphql": "4.x-dev@dev",
"drupal/image_delta_formatter": "^1.x-dev",

54
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "4bfbf0626a4aa7d6c658e5482a8259ac",
"content-hash": "350fc178a837b5226811e5f48aeff358",
"packages": [
{
"name": "alchemy/zippy",
@ -7488,6 +7488,58 @@
"issues": "https://www.drupal.org/project/issues/flag_lists"
}
},
{
"name": "drupal/flood_control",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/flood_control.git",
"reference": "2.1.1"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/flood_control-2.1.1.zip",
"reference": "2.1.1",
"shasum": "b8384e1673b92b0bdd8630624528c32fb7ef5f54"
},
"require": {
"drupal/core": "^8 || ^9"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "2.1.1",
"datestamp": "1609933716",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0-or-later"
],
"authors": [
{
"name": "Dave Reid",
"homepage": "https://www.drupal.org/user/53892"
},
{
"name": "batigolix",
"homepage": "https://www.drupal.org/user/22175"
},
{
"name": "fabianderijk",
"homepage": "https://www.drupal.org/user/278745"
}
],
"description": "Allows configuring hidden flood control options and unblocking IP addresses and user ID's that are blocked after multiple failed login attempts.",
"homepage": "https://www.drupal.org/project/flood_control",
"support": {
"source": "https://git.drupalcode.org/project/flood_control"
}
},
{
"name": "drupal/genpass",
"version": "dev-1.x",

View File

@ -83,6 +83,7 @@ module:
filter_perms: 0
flag: 0
flag_lists: 0
flood_control: 0
genpass: 0
graphql: 0
help: 0

View File

@ -23,6 +23,7 @@ negotiation:
language-url-fallback: 1
language_interface:
enabled:
language-graphql-operation: -999
language-url: -20
language-browser: -18
language-selected: -17

View File

@ -47,6 +47,9 @@ third_party_settings:
index_prefix: ''
collection: ''
timezone: ''
term_modifiers:
slop: 10000000
fuzzy: 2
id: autocomplete
name: 'autocomplete taxonomy'
description: ''

View File

@ -43,6 +43,9 @@ third_party_settings:
fragsize: 0
advanced:
index_prefix: ''
term_modifiers:
slop: 10000000
fuzzy: 2
id: database
name: database
description: ''

View File

@ -49,6 +49,7 @@ backend_config:
http_method: AUTO
jmx: false
solr_install_dir: ../../..
skip_schema_check: false
disabled_field_types: { }
disabled_caches: { }
disabled_request_handlers:
@ -60,10 +61,10 @@ backend_config:
rows: 10
retrieve_data: true
highlight_data: false
skip_schema_check: false
server_prefix: ''
domain: generic
environment: default
optimize: false
site_hash: true
index_single_documents_fallback_count: 10
fallback_multiple: true

View File

@ -49,6 +49,7 @@ backend_config:
http_method: AUTO
jmx: false
solr_install_dir: ../../..
skip_schema_check: false
disabled_field_types: { }
disabled_caches: { }
disabled_request_handlers:
@ -60,10 +61,10 @@ backend_config:
rows: 10
retrieve_data: true
highlight_data: false
skip_schema_check: false
server_prefix: ''
domain: generic
environment: default
optimize: false
site_hash: true
index_single_documents_fallback_count: 10
fallback_multiple: true

View File

@ -15,15 +15,15 @@ use \Drupal\Core\Link;
*
*/
function materio_user_form_user_login_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Drupal::logger('materio_user')->notice(print_r($form, true));
$form['name']['#attributes'] += array(
"v-model" => "mail",
"@keyup.enter" => "login"
// "@keyup.enter" => "login"
);
$form['pass']['#attributes'] = array(
"v-model" => "password",
"@keyup.enter" => "login"
// "@keyup.enter" => "login"
);
$url = Url::fromRoute('user.pass');
@ -34,6 +34,14 @@ function materio_user_form_user_login_form_alter(&$form, FormStateInterface $for
"@click.prevent" => "login"
);
$form['message'] = array(
'#markup' => '
<span class="login-message" v-if="loginMessage">
{{ loginMessage }}
</span>
'
);
}
function materio_user_form_user_modal_form_alter(&$form, FormStateInterface $form_state, $form_id) {

View File

@ -1263,7 +1263,7 @@ header[role="banner"] {
background-color: #fff;
overflow: hidden;
width: 11em;
height: 0px;
max-height: 0px;
padding: 0.01em 1em;
box-sizing: content-box;
transition: all 0.4s ease-in-out;
@ -1271,10 +1271,11 @@ header[role="banner"] {
position: absolute;
right: 0;
top: 1.7em;
box-sizing: content-box; }
box-sizing: content-box;
z-index: 100; }
header[role="banner"] #block-userlogin:hover > section {
transition-delay: 0s;
height: 12em;
max-height: 20em;
padding: 1em 1em;
box-shadow: 0 0 10px #ccc; }
header[role="banner"] #block-userlogin .form-item {
@ -1306,6 +1307,12 @@ header[role="banner"] {
margin: 0; }
header[role="banner"] #block-userlogin .item-list ul li a {
font-size: 0.756em; }
header[role="banner"] #block-userlogin span.login-message {
color: red;
font-size: 0.693em;
line-height: 1.2;
display: block;
padding: 0 0 0.8em 0; }
header[role="banner"] #block-userblock h2 {
display: none; }
header[role="banner"] #block-userblock a {
@ -2375,6 +2382,12 @@ article.card {
display: block;
max-width: 16em;
font-size: 0.693em; }
#pricing-modal-login-register #login-register > section form span.login-message {
color: red;
font-size: 0.693em;
line-height: 1.2;
display: block;
padding: 0 0 0.8em 0; }
#main-content form.commerce-checkout-flow {
max-width: 641px; }

File diff suppressed because one or more lines are too long

View File

@ -51,7 +51,7 @@ header[role="banner"]{
background-color: #fff;
overflow: hidden;
width:11em;
height:0px;
max-height:0px;
padding:0.01em 1em;
// margin:0 0 0 -1em;
box-sizing:content-box;
@ -62,11 +62,12 @@ header[role="banner"]{
right:0;
top:1.7em;
box-sizing: content-box;
z-index:100;
}
&:hover{
&>section{
transition-delay: 0s;
height:12em;
max-height:20em;
padding:1em 1em;
box-shadow: 0 0 10px #ccc;
}
@ -113,6 +114,13 @@ header[role="banner"]{
}
}
}
span.login-message{
color: red;
font-size: 0.693em;
line-height: 1.2;
display: block;
padding: 0 0 0.8em 0;
}
}
// non-vue userblock
@ -1663,6 +1671,14 @@ article.card{
max-width: 16em;
font-size: 0.693em;
}
span.login-message{
color: red;
font-size: 0.693em;
line-height: 1.2;
display: block;
padding: 0 0 0.8em 0;
}
}
}
section.login{

View File

@ -15,9 +15,11 @@ export default {
password: ''
}
},
// computed: {
// ...mapState(['User'])
// },
computed: {
...mapState({
loginMessage: state => state.User.loginMessage,
})
},
methods: {
...mapActions({
userLogin: 'User/userLogin'

View File

@ -11,6 +11,11 @@ export default {
mail:null,
password:null
}),
computed: {
...mapState({
loginMessage: state => state.User.loginMessage,
})
},
methods: {
...mapActions({
userLogin: 'User/userLogin'

View File

@ -18,6 +18,7 @@ export default {
mail: '',
csrf_token: null,
logout_token: null,
loginMessage: '',
isloggedin: false,
isAdmin: false,
isAdherent: false,
@ -38,6 +39,7 @@ export default {
state.csrf_token = token
},
setToken (state, data) {
console.log('setToken', data)
state.uid = data.current_user.uid
// state.username = data.username;
state.mail = data.current_user.mail
@ -45,6 +47,10 @@ export default {
state.isloggedin = true
state.logout_token = data.logout_token
},
setLoginMessage (state, message) {
console.log('setLoginMessage', message);
state.loginMessage = message
},
setUid (state, uid) {
state.uid = uid
state.isloggedin = true
@ -147,13 +153,21 @@ export default {
dispatch('getToken', credentials)
// TODO: catch failed login
.then(() => {
dispatch('getUser').then(userdata => {
console.log('User Loggedin')
if (state.isAdmin) {
window.location.reload(true)
}
resolve()
})
// there no response here, check the original getToken method
// console.log('dispatch getToken response', response);
// check if getToken (login) went well
if(state.isloggedin){
dispatch('getUser').then(userdata => {
console.log('User Loggedin')
if (state.isAdmin) {
window.location.reload(true)
}
resolve()
})
}else{
console.log('user loggein failed')
Promise.reject('user loggein failed')
}
})
.catch(error => {
console.warn('Issue with Dispatch getToken', error)
@ -162,10 +176,22 @@ export default {
})
},
getToken ({ dispatch, commit, state }, credentials) {
return REST.post('/user/login?_format=json', credentials)
.then(({ data }) => {
console.log('user REST getToken data', data)
commit('setToken', data)
return REST.post('/user/login?_format=json',
credentials,
{
validateStatus: function (status) {
return status >= 200 && status < 500;
}
})
.then((response) => {
console.log('user REST getToken response', response)
if(response.status === 200){
commit('setToken', response.data)
}else if(response.data.message){
commit('setLoginMessage', response.data.message)
}else{
console.warn('Issue with getToken', response)
}
})
.catch(error => {
console.warn('Issue with getToken', error)