Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 4ebfa716

Přidáno uživatelem Vojtěch Bartička před asi 2 roky(ů)

Check if password is empty or null

Zobrazit rozdíly:

Backend/Core/Services/UserService/UserServiceEF.cs
28 28

  
29 29
        public User ChangePassword(User user, string newPassword)
30 30
        {
31
            if (newPassword == "")
32
            {
33
                throw new InvalidOperationException("Empty password.");
34
            }
35

  
31 36
            // Check if the user is tracked by EF
32 37
            if (!_databaseContext.Users.Local.Any(u => u.Id == user.Id))
33 38
            {
......
62 67

  
63 68
        public User? CreateUser(string username, string name, string surname, string password, ERole role)
64 69
        {
70
            if (password == "")
71
            {
72
                return null;
73
            }
74

  
65 75
            // Check if username already used
66 76
            if (_databaseContext.Users.Any(u => u.Username == username))
67 77
            {
......
121 131
                throw new InvalidOperationException("User is untracked by EF.");
122 132
            }
123 133

  
124
            if (username is not null)
134
            if (username is not null && username != "")
125 135
            {
126 136
                user.Username = username;
127 137
            }
128 138

  
129
            if (name is not null)
139
            if (name is not null && name != "")
130 140
            {
131 141
                user.Name = name;
132 142
            }
133 143

  
134
            if (surname is not null)
144
            if (surname is not null && surname != "")
135 145
            {
136 146
                user.Surname = surname;
137 147
            }

Také k dispozici: Unified diff