Commit 7fc4b120bf35daa5d3d96eb565ec7d79ce153653

Fix RegisterDialog tab order and detail lengths
  
3232#include "gui/widgets/textfield.h"
3333
3434#include "net/logindata.h"
35#include "net/loginhandler.h"
36#include "net/net.h"
3537
3638#include "utils/gettext.h"
3739#include "utils/stringutils.h"
118118 std::stringstream errorMessage;
119119 int error = 0;
120120
121 if (newFirstEmail.length() < LEN_MIN_PASSWORD)
121 unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
122 unsigned int max = Net::getLoginHandler()->getMaxPasswordLength();
123
124 if (newFirstEmail.length() < min)
122125 {
123126 // First email address too short
124127 errorMessage << strprintf(_("The new email address needs to be at "
125 "least %d characters long."),
126 LEN_MIN_PASSWORD);
128 "least %d characters long."), min);
127129 error = 1;
128130 }
129 else if (newFirstEmail.length() > LEN_MAX_PASSWORD - 1 )
131 else if (newFirstEmail.length() > max - 1 )
130132 {
131133 // First email address too long
132134 errorMessage << strprintf(_("The new email address needs to be "
133 "less than %d characters long."),
134 LEN_MAX_PASSWORD);
135 "less than %d characters long."), max);
135136 error = 1;
136137 }
137138 else if (newFirstEmail != newSecondEmail)
  
3434#include "gui/widgets/layout.h"
3535
3636#include "net/logindata.h"
37#include "net/loginhandler.h"
38#include "net/net.h"
3739
3840#include "utils/gettext.h"
3941#include "utils/stringutils.h"
100100 std::stringstream errorMessage;
101101 int error = 0;
102102
103 unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
104 unsigned int max = Net::getLoginHandler()->getMaxPasswordLength();
105
103106 // Check old Password
104107 if (oldPassword.empty())
105108 {
110110 errorMessage << _("Enter the old password first.");
111111 error = 1;
112112 }
113 else if (newFirstPass.length() < LEN_MIN_PASSWORD)
113 else if (newFirstPass.length() < min)
114114 {
115115 // First password too short
116 errorMessage << strprintf(_("The new password needs to be at least "
117 "%d characters long."), LEN_MIN_PASSWORD);
116 errorMessage << strprintf(_("The new password needs to be at least"
117 " %d characters long."), min);
118118 error = 2;
119119 }
120 else if (newFirstPass.length() > LEN_MAX_PASSWORD - 1 )
120 else if (newFirstPass.length() > max - 1 )
121121 {
122122 // First password too long
123123 errorMessage << strprintf(_("The new password needs to be less "
124 "than %d characters long."),
125 LEN_MAX_PASSWORD);
124 "than %d characters long."), max);
126125 error = 2;
127126 }
128127 else if (newFirstPass != newSecondPass)
  
3737#include "gui/widgets/textfield.h"
3838
3939#include "net/logindata.h"
40#include "net/net.h"
4140#include "net/loginhandler.h"
41#include "net/net.h"
4242
4343#include "utils/gettext.h"
4444#include "utils/stringutils.h"
7979 place(0, 1, passwordLabel);
8080 place(0, 2, confirmLabel);
8181
82 place(1, 0, mUserField, 3).setPadding(2);
83 place(1, 1, mPasswordField, 3).setPadding(2);
84 place(1, 2, mConfirmField, 3).setPadding(2);
85
86 int row = 3;
87
8288 if (optionalActions & Net::LoginHandler::SetGenderOnRegister)
8389 {
8490 mMaleButton = new RadioButton(_("Male"), "sex", true);
8591 mFemaleButton = new RadioButton(_("Female"), "sex", false);
86 place(1, 3, mMaleButton);
87 place(2, 3, mFemaleButton);
92 place(1, row, mMaleButton);
93 place(2, row, mFemaleButton);
94
95 row++;
8896 }
8997
9098 if (optionalActions & Net::LoginHandler::SetEmailOnRegister)
9199 {
92100 gcn::Label *emailLabel = new Label(_("Email:"));
93101 mEmailField = new TextField;
94 place(0, 3, emailLabel);
95 place(1, 3, mEmailField, 3).setPadding(2);
102 place(0, row, emailLabel);
103 place(1, row, mEmailField, 3).setPadding(2);
104
105 row++;
96106 }
97107
98 place(1, 0, mUserField, 3).setPadding(2);
99 place(1, 1, mPasswordField, 3).setPadding(2);
100 place(1, 2, mConfirmField, 3).setPadding(2);
101108 place = getPlacer(0, 2);
102109 place(1, 0, mRegisterButton);
103110 place(2, 0, mCancelButton);
154154 std::string errorMessage;
155155 int error = 0;
156156
157 if (user.length() < LEN_MIN_USERNAME)
157 unsigned int minUser = Net::getLoginHandler()->getMinUserNameLength();
158 unsigned int maxUser = Net::getLoginHandler()->getMaxUserNameLength();
159 unsigned int minPass = Net::getLoginHandler()->getMinPasswordLength();
160 unsigned int maxPass = Net::getLoginHandler()->getMaxPasswordLength();
161
162 if (user.length() < minUser)
158163 {
159164 // Name too short
160165 errorMessage = strprintf
161166 (_("The username needs to be at least %d characters long."),
162 LEN_MIN_USERNAME);
167 minUser);
163168 error = 1;
164169 }
165 else if (user.length() > LEN_MAX_USERNAME - 1 )
170 else if (user.length() > maxUser - 1 )
166171 {
167172 // Name too long
168173 errorMessage = strprintf
169174 (_("The username needs to be less than %d characters long."),
170 LEN_MAX_USERNAME);
175 maxUser);
171176 error = 1;
172177 }
173 else if (mPasswordField->getText().length() < LEN_MIN_PASSWORD)
178 else if (mPasswordField->getText().length() < minPass)
174179 {
175180 // Pass too short
176181 errorMessage = strprintf
177182 (_("The password needs to be at least %d characters long."),
178 LEN_MIN_PASSWORD);
183 minPass);
179184 error = 2;
180185 }
181 else if (mPasswordField->getText().length() > LEN_MAX_PASSWORD - 1 )
186 else if (mPasswordField->getText().length() > maxPass - 1 )
182187 {
183188 // Pass too long
184189 errorMessage = strprintf
185190 (_("The password needs to be less than %d characters long."),
186 LEN_MAX_PASSWORD);
191 maxPass);
187192 error = 2;
188193 }
189194 else if (mPasswordField->getText() != mConfirmField->getText())
  
3434#include "gui/widgets/textfield.h"
3535
3636#include "net/logindata.h"
37#include "net/loginhandler.h"
38#include "net/net.h"
3739
3840#include "utils/gettext.h"
3941#include "utils/stringutils.h"
108108 std::stringstream errorMessage;
109109 bool error = false;
110110
111 unsigned int min = Net::getLoginHandler()->getMinPasswordLength();
112 unsigned int max = Net::getLoginHandler()->getMaxPasswordLength();
113
111114 // Check password
112 if (password.length() < LEN_MIN_PASSWORD)
115 if (password.length() < min)
113116 {
114117 // Pass too short
115118 errorMessage << strprintf(_("The password needs to be at least %d "
116 "characters long."), LEN_MIN_PASSWORD);
119 "characters long."), min);
117120 error = true;
118121 }
119 else if (password.length() > LEN_MAX_PASSWORD - 1)
122 else if (password.length() > max - 1)
120123 {
121124 // Pass too long
122125 errorMessage << strprintf(_("The password needs to be less than "
123 "%d characters long."),
124 LEN_MAX_PASSWORD);
126 "%d characters long."), max);
125127 error = true;
126128 }
127129
src/main.h
(0 / 11)
  
124124 STATE_FORCE_QUIT
125125};
126126
127/* length definitions for several char[]s in order
128 * to be able to use strncpy instead of strcpy for
129 * security and stability reasons
130 */
131enum {
132 LEN_MAX_USERNAME = 25,
133 LEN_MIN_USERNAME = 4,
134 LEN_MAX_PASSWORD = 25,
135 LEN_MIN_PASSWORD = 4
136};
137
138127extern State state;
139128extern std::string errorMessage;
140129
  
6363 */
6464 virtual int supportedOptionalActions() const = 0;
6565
66 virtual unsigned int getMinUserNameLength() const { return 4; };
67
68 virtual unsigned int getMaxUserNameLength() const { return 25; };
69
70 virtual unsigned int getMinPasswordLength() const { return 4; };
71
72 virtual unsigned int getMaxPasswordLength() const { return 25; };
73
6674 virtual void loginAccount(LoginData *loginData) = 0;
6775
6876 virtual void logout() = 0;
  
4747 int supportedOptionalActions() const
4848 { return Unregister | ChangeEmail | SetEmailOnRegister; }
4949
50 unsigned int getMaxUserNameLength() const { return 15; };
51
52 unsigned int getMinPasswordLength() const { return 6; };
53
5054 void loginAccount(LoginData *loginData);
5155
5256 void logout();