-primaryEmail: String
-locale: Locale
-Name
+-country: varchar(2)
--
+hasPassedCATS(): boolean
+isInGroup(:Group): boolean
}
- public static final int CURRENT_SCHEMA_VERSION = 22;
+ public static final int CURRENT_SCHEMA_VERSION = 23;
public static final int CONNECTION_TIMEOUT = 24 * 60 * 60;
"dob" date NOT NULL,
"verified" boolean NOT NULL DEFAULT 'false',
"language" varchar(5) NOT NULL DEFAULT '',
+ "country" varchar(2) NULL,
PRIMARY KEY ("id")
);
CREATE INDEX ON "users" ("email");
"version" smallint NOT NULL,
PRIMARY KEY ("version")
);
-INSERT INTO "schemeVersion" (version) VALUES(22);
+INSERT INTO "schemeVersion" (version) VALUES(23);
DROP TABLE IF EXISTS `passwordResetTickets`;
CREATE TABLE `passwordResetTickets` (
--- /dev/null
+ALTER TABLE "users" ADD COLUMN "country" varchar(2) NULL;
\ No newline at end of file
private Name preferredName;
+ private CountryCode residenceCountry;
+
protected User(GigiResultSet rs) {
super(rs.getInt("id"));
updateName(rs);
email = rs.getString("email");
preferredName = Name.getById(rs.getInt("preferredName"));
+ try {
+ if (rs.getString("Country") != null) {
+ residenceCountry = CountryCode.getCountryCode(rs.getString("Country"), CountryCode.CountryCodeType.CODE_2_CHARS);
+ }
+ } catch (GigiApiException e) {
+ throw new Error(e);
+ }
+
String localeStr = rs.getString("language");
if (localeStr == null || localeStr.equals("")) {
locale = Locale.getDefault();
}
}
- public User(String email, String password, DayDate dob, Locale locale, NamePart... preferred) throws GigiApiException {
+ public User(String email, String password, DayDate dob, Locale locale, CountryCode residenceCountry, NamePart... preferred) throws GigiApiException {
this.email = email;
this.dob = dob;
this.locale = locale;
this.preferredName = new Name(this, preferred);
- try (GigiPreparedStatement query = new GigiPreparedStatement("INSERT INTO `users` SET `email`=?, `password`=?, `dob`=?, `language`=?, id=?, `preferredName`=?")) {
+ try (GigiPreparedStatement query = new GigiPreparedStatement("INSERT INTO `users` SET `email`=?, `password`=?, `dob`=?, `language`=?, id=?, `preferredName`=?, `country` = ?")) {
query.setString(1, email);
query.setString(2, PasswordHash.hash(password));
query.setDate(3, dob.toSQLDate());
query.setString(4, locale.toString());
query.setInt(5, getId());
query.setInt(6, preferredName.getId());
+ query.setString(7, residenceCountry == null ? null : residenceCountry.getCountryCode());
query.execute();
}
new EmailAddress(this, email, locale);
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {}
+ public CountryCode getResidenceCountry() {
+ return residenceCountry;
+ }
+
+ public void setResidenceCountry(CountryCode residenceCountry) {
+ this.residenceCountry = residenceCountry;
+ rawUpdateCountryData();
+ }
+
+ private void rawUpdateCountryData() {
+ try (GigiPreparedStatement update = new GigiPreparedStatement("UPDATE users SET country=? WHERE id=?")) {
+ update.setString(1, residenceCountry == null ? null : residenceCountry.getCountryCode());
+ update.setInt(2, getId());
+ update.executeUpdate();
+ }
+ }
}
import org.cacert.gigi.dbObjects.User;
import org.cacert.gigi.localisation.Language;
import org.cacert.gigi.output.ArrayIterable;
+import org.cacert.gigi.output.CountrySelector;
import org.cacert.gigi.output.DateSelector;
import org.cacert.gigi.output.NameInput;
import org.cacert.gigi.output.template.Form;
private NameInput ni;
+ private CountrySelector cs;
+
public MyDetailsForm(HttpServletRequest hsr, User target) {
super(hsr);
this.target = target;
ni = new NameInput();
this.ds = new DateSelector("day", "month", "year", target.getDoB());
+
+ if (target.getResidenceCountry() == null) {
+ this.cs = new CountrySelector("residenceCountry", true);
+ } else {
+ this.cs = new CountrySelector("residenceCountry", true, target.getResidenceCountry());
+ }
}
@Override
ds.update(req);
target.setDoB(ds.getDate());
}
+ if ("updateResidenceCountry".equals(action)) {
+ cs.update(req);
+ target.setResidenceCountry(cs.getCountry());
+ }
} catch (GigiApiException e) {
e.format(out, Page.getLanguage(req));
return false;
});
vars.put("name", ni);
names.output(out, l, vars);
+ vars.put("residenceCountry", cs);
if (target.getReceivedAssurances().length == 0) {
vars.put("DoB", ds);
templ.output(out, l, vars);
<button class="btn btn-primary pull-right" name="action" value="updateDoB"><?=_Update Date of Birth?></button>
</div>
</div>
+<div class="panel panel-default">
+ <div class="panel-heading"><?=_Residence Country?></div>
+ <div class="panel-body">
+ <?=$residenceCountry?>
+ <button class="btn btn-primary pull-right" name="action" value="updateResidenceCountry"><?=_Update Residence Country?></button>
+ </div>
+</div>
<a href="/account/history"><?=_Show account history?></a>
<?=$DoB?>
</div>
</div>
+<div class="panel panel-default">
+ <div class="panel-heading"><?=_Residence Country?></div>
+ <div class="panel-body">
+ <?=$residenceCountry?>
+ <button class="btn btn-primary pull-right" name="action" value="updateResidenceCountry"><?=_Update Residence Country?></button>
+ </div>
+</div>
<a href="/account/history"><?=_Show account history?></a>
import org.cacert.gigi.dbObjects.User;
import org.cacert.gigi.email.EmailProvider;
import org.cacert.gigi.localisation.Language;
+import org.cacert.gigi.output.CountrySelector;
import org.cacert.gigi.output.DateSelector;
import org.cacert.gigi.output.NameInput;
import org.cacert.gigi.output.template.Form;
private boolean general = true, country = true, regional = true, radius = true;
+ private CountrySelector cs;
+
public Signup(HttpServletRequest hsr) {
super(hsr);
ni = new NameInput();
+ cs = new CountrySelector("residenceCountry", true);
}
private DateSelector myDoB = new DateSelector("day", "month", "year");
vars.put("helpOnNames", String.format(l.getTranslation("Help on Names %sin the wiki%s"), "<a href=\"//wiki.cacert.org/FAQ/HowToEnterNamesInJoinForm\" target=\"_blank\">", "</a>"));
vars.put("csrf", getCSRFToken());
vars.put("dobmin", User.MINIMUM_AGE + "");
+ vars.put("countryCode", cs);
t.output(out, l, vars);
}
} catch (GigiApiException e) {
problems.mergeInto(e);
}
+
+ cs.update(r);
+
if ( !problems.isEmpty()) {
throw problems;
}
+
}
@Override
}
private void run(HttpServletRequest req, String password) throws GigiApiException {
- User u = new User(email, password, myDoB.getDate(), Page.getLanguage(req).getLocale(), ni.getNameParts());
+ User u = new User(email, password, myDoB.getDate(), Page.getLanguage(req).getLocale(), cs.getCountry(), ni.getNameParts());
try (GigiPreparedStatement ps = new GigiPreparedStatement("INSERT INTO `alerts` SET `memid`=?," + " `general`=?, `country`=?, `regional`=?, `radius`=?")) {
ps.setInt(1, u.getId());
ps.execute();
}
Notary.writeUserAgreement(u, "ToS", "account creation", "", true, 0);
-
}
+
}
<th colspan="3"><?=_My Details?></th>
</tr>
</thead>
+
<tbody>
<tr>
<td><?=_Name?>: </td>
<td><?=$name?></td>
<td rowspan="4"><?=$!helpOnNames?></td>
</tr>
+
<tr>
- <td><?=_Date of Birth (minimum age: ${dobmin} years)?><br>
+ <td><?=_Date of Birth?>:<br>
(<?=_yyyy-mm-dd?>)</td>
<td><?=$dob?></td>
- <td> </td>
+ <td><?=_The required minimum age is ${dobmin} years.?></td>
</tr>
<tr>
- <td><?=_Email Address?>: </td>
+ <td><?=_Residence Country?>:</td>
+ <td><?=$countryCode?></td>
+ <td><?=_The country in which you currently reside. This information is optional and used for statistical purposes only.?></td>
+ </tr>
+
+ <tr>
+ <td><?=_Email Address?>:</td>
<td><input type="text" name="email" size="30" value="<?=$email?>" autocomplete="off"></td>
<td><?=_I own or am authorised to control this email address?></td>
</tr>
<td><input class="form-control" type="password" name="pword1" size="30" autocomplete="off"></td>
<td rowspan="2"> </td>
</tr>
+
<tr>
<td><?=_Pass Phrase Again?><font color="red">*</font>: </td>
<td><input class="form-control" type="password" name="pword2" size="30" autocomplete="off"></td>
c.set(1950, 1, 1, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
- User u = new User(createUniqueName() + "@email.com", TEST_PASSWORD, new DayDate(c.getTimeInMillis()), Locale.ENGLISH, //
+ User u = new User(createUniqueName() + "@email.com", TEST_PASSWORD, new DayDate(c.getTimeInMillis()), Locale.ENGLISH, null, //
new NamePart(NamePartType.FIRST_NAME, "a"), new NamePart(NamePartType.FIRST_NAME, "m"), new NamePart(NamePartType.LAST_NAME, "c"));
InVMEmail.getInstance().mails.poll().verify();
return u;
c.set(1950, 1, 1, 0, 0, 0);
c.set(Calendar.MILLISECOND, 0);
- User u = new User(mail, pw, new DayDate(c.getTimeInMillis()), Locale.ENGLISH,//
+ User u = new User(mail, pw, new DayDate(c.getTimeInMillis()), Locale.ENGLISH, null, //
new NamePart(NamePartType.FIRST_NAME, f), new NamePart(NamePartType.LAST_NAME, l));
return u;
}
Calendar gc = GregorianCalendar.getInstance();
gc.setTimeInMillis(0);
gc.set(1990, 0, 1);
- User u = new User(email, "xvXV12°§", new DayDate(gc.getTime().getTime()), Locale.ENGLISH, //
+ User u = new User(email, "xvXV12°§", new DayDate(gc.getTime().getTime()), Locale.ENGLISH, null, //
new NamePart(NamePartType.FIRST_NAME, "Först"), new NamePart(NamePartType.FIRST_NAME, "Müddle"),//
new NamePart(NamePartType.LAST_NAME, "Läst"), new NamePart(NamePartType.SUFFIX, "Süffix"));
EmailAddress ea = u.getEmails()[0];