Skip to content

Commit

Permalink
Follow-up Fixes (#767)
Browse files Browse the repository at this point in the history
Found a couple of issues by the previous fix. So this is to fix those.

Changelog:

Fixed logout
If a user has multiple records of the same role, it should no longer make the checkbox unclickable
Removed validation from Phones as it's causing confusing behaviour
  • Loading branch information
amichard authored and kuanfandevops committed Dec 12, 2018
1 parent 4005896 commit 324b617
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 9 deletions.
25 changes: 25 additions & 0 deletions backend/api/migrations/0047_auto_20181205_1716.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.13 on 2018-12-05 17:16
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('api', '0046_document_data_load'),
]

operations = [
migrations.AlterField(
model_name='user',
name='cell_phone',
field=models.CharField(blank=True, max_length=17, null=True),
),
migrations.AlterField(
model_name='user',
name='phone',
field=models.CharField(blank=True, max_length=17, null=True),
),
]
8 changes: 2 additions & 6 deletions backend/api/models/User.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ class User(AbstractUser, Auditable):
verbose_name='username',
db_comment='Login Username'
)
phone_regex = RegexValidator(
regex=r'^\+?1?\d{9,15}$',
message="Phone number must be entered in the "
"format: '+999999999'. Up to 15 digits allowed.")

password = models.CharField(
max_length=128, blank=True, null=True, db_comment='Password hash')
Expand All @@ -61,10 +57,10 @@ class User(AbstractUser, Auditable):
title = models.CharField(
max_length=100, blank=True, null=True, db_comment='Professional Title')
phone = models.CharField(
validators=[phone_regex], max_length=17, blank=True, null=True,
max_length=17, blank=True, null=True,
db_comment='Primary phone number')
cell_phone = models.CharField(
validators=[phone_regex], max_length=17, blank=True, null=True,
max_length=17, blank=True, null=True,
db_comment='Mobile phone number')
organization = models.ForeignKey(
'Organization', related_name='users', blank=True, null=True,
Expand Down
12 changes: 12 additions & 0 deletions frontend/src/admin/users/UserEditContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,18 @@ class UserEditContainer extends Component {
fieldState.roles[index].value = !fieldState.roles[index].value;
}

// search for duplicates and get rid of them. they should be very unlikely, but just in case
const indexesFound = [];
fieldState.roles.forEach((role) => {
if (role.id === key) {
indexesFound.push(role);
}
});

if (indexesFound.length > 1) {
fieldState.roles.splice(index, 1);
}

this.setState({
fields: fieldState
});
Expand Down
8 changes: 5 additions & 3 deletions frontend/src/app/components/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ class Navbar extends Component {
{CONFIG.KEYCLOAK.ENABLED &&
<NavLink
id="navbar-logout"
onClick={(e) => { e.preventDefault(); this.props.dispatch(signUserOut()); }}
onClick={(e) => { e.preventDefault(); this.props.signUserOut(); }}
to={Routes.LOGOUT}
>
Log Out
Expand Down Expand Up @@ -364,7 +364,7 @@ class Navbar extends Component {
</MenuItem>
{CONFIG.KEYCLOAK.ENABLED &&
<MenuItem onClick={(e) => {
e.preventDefault(); this.props.dispatch(signUserOut());
e.preventDefault(); this.props.signUserOut();
}}
>
<FontAwesomeIcon icon="sign-out-alt" /> Log Out
Expand Down Expand Up @@ -416,11 +416,13 @@ Navbar.propTypes = {
id: PropTypes.number
}))
}).isRequired,
signUserOut: PropTypes.func.isRequired,
unreadNotificationsCount: PropTypes.number
};

const mapDispatchToProps = dispatch => ({
getNotifications: bindActionCreators(getNotifications, dispatch)
getNotifications: bindActionCreators(getNotifications, dispatch),
signUserOut: bindActionCreators(signUserOut, dispatch)
});

// export default Navbar;
Expand Down
5 changes: 5 additions & 0 deletions rmconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"pullRequest": {
"maxLinesChanged": 1000
}
}

0 comments on commit 324b617

Please sign in to comment.