Allow changes of users phone and email contact info by the user
This commit is contained in:
parent
3e63b9ce46
commit
c8e634156b
@ -5507,9 +5507,10 @@ namespace BreCalClient.misc.Model
|
||||
/// <param name="lastName">lastName.</param>
|
||||
/// <param name="userName">userName.</param>
|
||||
/// <param name="userPhone">userPhone.</param>
|
||||
/// <param name="userEmail">userEmail.</param>
|
||||
/// <param name="exp">exp.</param>
|
||||
/// <param name="token">token.</param>
|
||||
public LoginResult(int id = default(int), int participantId = default(int), string firstName = default(string), string lastName = default(string), string userName = default(string), string userPhone = default(string), float exp = default(float), string token = default(string))
|
||||
public LoginResult(int id = default(int), int participantId = default(int), string firstName = default(string), string lastName = default(string), string userName = default(string), string userPhone = default(string), string userEmail = default(string), float exp = default(float), string token = default(string))
|
||||
{
|
||||
this.Id = id;
|
||||
this.ParticipantId = participantId;
|
||||
@ -5517,6 +5518,7 @@ namespace BreCalClient.misc.Model
|
||||
this.LastName = lastName;
|
||||
this.UserName = userName;
|
||||
this.UserPhone = userPhone;
|
||||
this.UserEmail = userEmail;
|
||||
this.Exp = exp;
|
||||
this.Token = token;
|
||||
}
|
||||
@ -5551,6 +5553,11 @@ namespace BreCalClient.misc.Model
|
||||
[DataMember(Name = "user_phone", EmitDefaultValue = true)]
|
||||
public string UserPhone { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets UserEmail
|
||||
/// </summary>
|
||||
[DataMember(Name = "user_email", EmitDefaultValue = true)]
|
||||
public string UserEmail { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets Exp
|
||||
/// </summary>
|
||||
[DataMember(Name = "exp", EmitDefaultValue = true)]
|
||||
@ -5574,6 +5581,7 @@ namespace BreCalClient.misc.Model
|
||||
sb.Append(" LastName: ").Append(LastName).Append("\n");
|
||||
sb.Append(" UserName: ").Append(UserName).Append("\n");
|
||||
sb.Append(" UserPhone: ").Append(UserPhone).Append("\n");
|
||||
sb.Append(" UserEmail: ").Append(UserEmail).Append("\n");
|
||||
sb.Append(" Exp: ").Append(Exp).Append("\n");
|
||||
sb.Append(" Token: ").Append(Token).Append("\n");
|
||||
sb.Append("}\n");
|
||||
@ -5636,6 +5644,11 @@ namespace BreCalClient.misc.Model
|
||||
(this.UserPhone != null &&
|
||||
this.UserPhone.Equals(input.UserPhone))
|
||||
) &&
|
||||
(
|
||||
this.UserEmail == input.UserEmail ||
|
||||
(this.UserEmail != null &&
|
||||
this.UserEmail.Equals(input.UserEmail))
|
||||
) &&
|
||||
(
|
||||
this.Exp == input.Exp ||
|
||||
this.Exp.Equals(input.Exp)
|
||||
@ -5673,6 +5686,10 @@ namespace BreCalClient.misc.Model
|
||||
{
|
||||
hashCode = (hashCode * 59) + this.UserPhone.GetHashCode();
|
||||
}
|
||||
if (this.UserEmail != null)
|
||||
{
|
||||
hashCode = (hashCode * 59) + this.UserEmail.GetHashCode();
|
||||
}
|
||||
hashCode = (hashCode * 59) + this.Exp.GetHashCode();
|
||||
if (this.Token != null)
|
||||
{
|
||||
@ -7627,7 +7644,8 @@ namespace BreCalClient.misc.Model
|
||||
/// <param name="firstName">firstName.</param>
|
||||
/// <param name="lastName">lastName.</param>
|
||||
/// <param name="userPhone">userPhone.</param>
|
||||
public UserDetails(int id = default(int), string oldPassword = default(string), string newPassword = default(string), string firstName = default(string), string lastName = default(string), string userPhone = default(string))
|
||||
/// <param name="userEmail">userEmail.</param>
|
||||
public UserDetails(int id = default(int), string oldPassword = default(string), string newPassword = default(string), string firstName = default(string), string lastName = default(string), string userPhone = default(string), string userEmail = default(string))
|
||||
{
|
||||
this.Id = id;
|
||||
this.OldPassword = oldPassword;
|
||||
@ -7635,6 +7653,7 @@ namespace BreCalClient.misc.Model
|
||||
this.FirstName = firstName;
|
||||
this.LastName = lastName;
|
||||
this.UserPhone = userPhone;
|
||||
this.UserEmail = userEmail;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or Sets Id
|
||||
@ -7667,6 +7686,11 @@ namespace BreCalClient.misc.Model
|
||||
[DataMember(Name = "user_phone", EmitDefaultValue = true)]
|
||||
public string UserPhone { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or Sets UserEmail
|
||||
/// </summary>
|
||||
[DataMember(Name = "user_email", EmitDefaultValue = true)]
|
||||
public string UserEmail { get; set; }
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
@ -7680,6 +7704,7 @@ namespace BreCalClient.misc.Model
|
||||
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
|
||||
sb.Append(" LastName: ").Append(LastName).Append("\n");
|
||||
sb.Append(" UserPhone: ").Append(UserPhone).Append("\n");
|
||||
sb.Append(" UserEmail: ").Append(UserEmail).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
@ -7740,6 +7765,11 @@ namespace BreCalClient.misc.Model
|
||||
this.UserPhone == input.UserPhone ||
|
||||
(this.UserPhone != null &&
|
||||
this.UserPhone.Equals(input.UserPhone))
|
||||
) &&
|
||||
(
|
||||
this.UserEmail == input.UserEmail ||
|
||||
(this.UserEmail != null &&
|
||||
this.UserEmail.Equals(input.UserEmail))
|
||||
);
|
||||
}
|
||||
/// <summary>
|
||||
@ -7772,6 +7802,10 @@ namespace BreCalClient.misc.Model
|
||||
{
|
||||
hashCode = (hashCode * 59) + this.UserPhone.GetHashCode();
|
||||
}
|
||||
if (this.UserEmail != null)
|
||||
{
|
||||
hashCode = (hashCode * 59) + this.UserEmail.GetHashCode();
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -696,6 +696,8 @@ components:
|
||||
type: string
|
||||
user_phone:
|
||||
type: string
|
||||
user_email:
|
||||
type: string
|
||||
exp:
|
||||
type: number
|
||||
format: float
|
||||
@ -723,6 +725,9 @@ components:
|
||||
user_phone:
|
||||
type: string
|
||||
nullable: true
|
||||
user_email:
|
||||
type: string
|
||||
nullable: true
|
||||
Id:
|
||||
type: object
|
||||
description: A unique identifier for an entity
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:p = "clr-namespace:BreCalClient.Resources"
|
||||
mc:Ignorable="d"
|
||||
Title="Help" Height="280" Width="500">
|
||||
Title="Help" Height="374" Width="500" Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="180" />
|
||||
@ -20,6 +20,10 @@
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="10" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
<RowDefinition Height="28" />
|
||||
@ -39,14 +43,20 @@
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
|
||||
<Label FontWeight="DemiBold" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textChangePassword}" HorizontalContentAlignment="Right"/>
|
||||
<Label FontWeight="DemiBold" Grid.Row="3" Grid.Column="0" Content="{x:Static p:Resources.textChangeContactInfo}" HorizontalContentAlignment="Right"/>
|
||||
<Label Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textEmail}" HorizontalContentAlignment="Right" />
|
||||
<Label Grid.Row="5" Grid.Column="0" Content="{x:Static p:Resources.textPhone}" HorizontalContentAlignment="Right" />
|
||||
<TextBox Name="textBoxUserEmail" Grid.Column="1" Grid.Row="4" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox Name="textBoxUserPhone" Grid.Column="1" Grid.Row="5" Margin="2" VerticalContentAlignment="Center" />
|
||||
|
||||
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textOldPassword}" Grid.Column="1" Grid.Row="3" Margin="2" x:Name="wpBoxOldPassword" TextChanged="wpBoxOldPassword_TextChanged"/>
|
||||
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textNewPassword}" Grid.Column="1" Grid.Row="4" Margin="2" x:Name="wpBoxNewPassword" TextChanged="wpBoxOldPassword_TextChanged"/>
|
||||
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textRepeatNewPassword}" Grid.Column="1" Grid.Row="5" Margin="2" x:Name="wpBoxNewPasswordRepeat" TextChanged="wpBoxOldPassword_TextChanged"/>
|
||||
<Button x:Name="buttonChangePassword" Click="buttonChangePassword_Click" Grid.Column="1" Grid.Row="6" Margin="2" Content="{x:Static p:Resources.textChange}" Width="80" HorizontalAlignment="Left" IsEnabled="False" />
|
||||
<Label FontWeight="DemiBold" Grid.Row="7" Grid.Column="0" Content="{x:Static p:Resources.textChangePassword}" HorizontalContentAlignment="Right"/>
|
||||
|
||||
<Button x:Name="buttonClose" Click="buttonClose_Click" Content="{x:Static p:Resources.textClose}" Width="80" Margin="2" Grid.Column="1" Grid.Row="8" HorizontalAlignment="Right" />
|
||||
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textOldPassword}" Grid.Column="1" Grid.Row="7" Margin="2" x:Name="wpBoxOldPassword" TextChanged="wpBoxOldPassword_TextChanged"/>
|
||||
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textNewPassword}" Grid.Column="1" Grid.Row="8" Margin="2" x:Name="wpBoxNewPassword" TextChanged="wpBoxOldPassword_TextChanged"/>
|
||||
<xctk:WatermarkPasswordBox Watermark="{x:Static p:Resources.textRepeatNewPassword}" Grid.Column="1" Grid.Row="9" Margin="2" x:Name="wpBoxNewPasswordRepeat" TextChanged="wpBoxOldPassword_TextChanged"/>
|
||||
<Button x:Name="buttonChangePassword" Click="buttonChangePassword_Click" Grid.Column="1" Grid.Row="10" Margin="2" Content="{x:Static p:Resources.textChange}" Width="80" HorizontalAlignment="Left" IsEnabled="False" />
|
||||
|
||||
<Button x:Name="buttonClose" Click="buttonClose_Click" Content="{x:Static p:Resources.textClose}" Width="80" Margin="2" Grid.Column="1" Grid.Row="12" HorizontalAlignment="Right" />
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// Description: Show about info and allow user detail editing
|
||||
//
|
||||
|
||||
using BreCalClient.misc.Model;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
@ -24,6 +25,12 @@ namespace BreCalClient
|
||||
|
||||
#endregion
|
||||
|
||||
#region Properties
|
||||
|
||||
public LoginResult? LoginResult { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
#region events
|
||||
|
||||
public event Action<string, string>? ChangePasswordRequested;
|
||||
@ -39,6 +46,12 @@ namespace BreCalClient
|
||||
|
||||
private void buttonChangePassword_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (this.LoginResult != null)
|
||||
{
|
||||
this.LoginResult.UserPhone = this.textBoxUserPhone.Text.Trim();
|
||||
this.LoginResult.UserEmail = this.textBoxUserEmail.Text.Trim();
|
||||
}
|
||||
|
||||
this.ChangePasswordRequested?.Invoke(this.wpBoxOldPassword.Password, this.wpBoxNewPassword.Password);
|
||||
}
|
||||
|
||||
@ -58,7 +71,15 @@ namespace BreCalClient
|
||||
(!this.wpBoxNewPassword.Password.Equals(this.wpBoxOldPassword.Password));
|
||||
}
|
||||
|
||||
#endregion
|
||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if(LoginResult != null)
|
||||
{
|
||||
this.textBoxUserEmail.Text = LoginResult.UserEmail;
|
||||
this.textBoxUserPhone.Text = LoginResult.UserPhone;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -192,6 +192,7 @@ namespace BreCalClient
|
||||
private void buttonInfo_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
AboutDialog ad = new();
|
||||
ad.LoginResult = this._loginResult;
|
||||
ad.ChangePasswordRequested += async (oldPw, newPw) =>
|
||||
{
|
||||
if (_loginResult != null)
|
||||
@ -202,6 +203,7 @@ namespace BreCalClient
|
||||
FirstName = _loginResult.FirstName,
|
||||
LastName = _loginResult.LastName,
|
||||
UserPhone = _loginResult.UserPhone,
|
||||
UserEmail = _loginResult.UserEmail,
|
||||
OldPassword = oldPw,
|
||||
NewPassword = newPw
|
||||
};
|
||||
|
||||
27
src/BreCalClient/Resources/Resources.Designer.cs
generated
27
src/BreCalClient/Resources/Resources.Designer.cs
generated
@ -346,6 +346,15 @@ namespace BreCalClient.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Update contact info.
|
||||
/// </summary>
|
||||
public static string textChangeContactInfo {
|
||||
get {
|
||||
return ResourceManager.GetString("textChangeContactInfo", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Change password.
|
||||
/// </summary>
|
||||
@ -436,6 +445,15 @@ namespace BreCalClient.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to E-mail.
|
||||
/// </summary>
|
||||
public static string textEmail {
|
||||
get {
|
||||
return ResourceManager.GetString("textEmail", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Enter keyword.
|
||||
/// </summary>
|
||||
@ -661,6 +679,15 @@ namespace BreCalClient.Resources {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Phone.
|
||||
/// </summary>
|
||||
public static string textPhone {
|
||||
get {
|
||||
return ResourceManager.GetString("textPhone", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Pier side.
|
||||
/// </summary>
|
||||
|
||||
@ -406,4 +406,13 @@
|
||||
<data name="textWidth" xml:space="preserve">
|
||||
<value>Breite</value>
|
||||
</data>
|
||||
<data name="textChangeContactInfo" xml:space="preserve">
|
||||
<value>Kontaktdaten bearbeiten</value>
|
||||
</data>
|
||||
<data name="textEmail" xml:space="preserve">
|
||||
<value>E-Mail</value>
|
||||
</data>
|
||||
<data name="textPhone" xml:space="preserve">
|
||||
<value>Telefon</value>
|
||||
</data>
|
||||
</root>
|
||||
@ -208,6 +208,9 @@
|
||||
<data name="textChange" xml:space="preserve">
|
||||
<value>Change</value>
|
||||
</data>
|
||||
<data name="textChangeContactInfo" xml:space="preserve">
|
||||
<value>Update contact info</value>
|
||||
</data>
|
||||
<data name="textChangePassword" xml:space="preserve">
|
||||
<value>Change password</value>
|
||||
</data>
|
||||
@ -238,6 +241,9 @@
|
||||
<data name="textEditTimes" xml:space="preserve">
|
||||
<value>Edit times</value>
|
||||
</data>
|
||||
<data name="textEmail" xml:space="preserve">
|
||||
<value>E-mail</value>
|
||||
</data>
|
||||
<data name="textEnterKeyword" xml:space="preserve">
|
||||
<value>Enter keyword</value>
|
||||
</data>
|
||||
@ -313,6 +319,9 @@
|
||||
<data name="textPasswordChanged" xml:space="preserve">
|
||||
<value>Password changed.</value>
|
||||
</data>
|
||||
<data name="textPhone" xml:space="preserve">
|
||||
<value>Phone</value>
|
||||
</data>
|
||||
<data name="textPierside" xml:space="preserve">
|
||||
<value>Pier side</value>
|
||||
</data>
|
||||
|
||||
@ -26,7 +26,8 @@ def GetUser(options):
|
||||
"first_name": data[0].first_name,
|
||||
"last_name": data[0].last_name,
|
||||
"user_name": data[0].user_name,
|
||||
"user_phone": data[0].user_phone
|
||||
"user_phone": data[0].user_phone,
|
||||
"user_email": data[0].user_email
|
||||
}
|
||||
token = jwt_handler.generate_jwt(payload=result, lifetime=120) # generate token valid 60 mins
|
||||
result["token"] = token # add token to user data
|
||||
|
||||
@ -27,7 +27,7 @@ def PutUser(schemaModel):
|
||||
return json.dumps("no such record"), 404, {'Content-Type': 'application/json; charset=utf-8'}
|
||||
|
||||
# see if we need to update public fields
|
||||
if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel:
|
||||
if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel or "user_email" in schemaModel:
|
||||
query = "UPDATE user SET "
|
||||
isNotFirst = False
|
||||
for key in schemaModel.keys():
|
||||
|
||||
@ -180,6 +180,7 @@ class UserSchema(Schema):
|
||||
first_name = fields.Str(Required=False, allow_none=True)
|
||||
last_name = fields.Str(required=False, allow_none=True)
|
||||
user_phone = fields.Str(required=False, allow_none=True)
|
||||
user_email = fields.Str(required=False, allow_none=True)
|
||||
old_password = fields.Str(required=False, allow_none=True)
|
||||
new_password = fields.Str(required=False, allow_none=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user