Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix activation link #594

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dev/META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Agrammon",
"description": "Simulation model for calculating ammonia and Nx/NOx emissions from agriculture.",
"version": "6.4.1",
"version": "6.4.2",
"perl": "6.*",
"authors": [
"Fritz Zaucker <[email protected]>",
Expand Down
22 changes: 12 additions & 10 deletions frontend/source/class/agrammon/module/dataset/DatasetTool.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,7 @@ qx.Class.define('agrammon.module.dataset.DatasetTool', {
this.__setDatasets = function() {
// used for datasetFilter
that.__datasets = this.__datasetCache.getDatasets();
if (! that.__datasets) return;
var len = that.__datasets.length;
if (len<1) return;

Expand All @@ -533,16 +534,17 @@ qx.Class.define('agrammon.module.dataset.DatasetTool', {

this.__setTags = function() {
var data = this.__datasetCache.getTags();
var len = data.length;
if (len<1) {
return;
}
var i, rec;
that.__availableTags = [];
for (i=0; i<len; i++) {
rec = [ data[i] ];
that.__availableTags.push(rec);
}
if (!data) return;
var len = data.length;
if (len<1) {
return;
}
var i, rec;
that.__availableTags = [];
for (i=0; i<len; i++) {
rec = [ data[i] ];
that.__availableTags.push(rec);
}
availableTagsTm.setData(that.__availableTags);
availableTagsTable.updateView();
}; // this.__setTags()
Expand Down
2 changes: 1 addition & 1 deletion frontend/source/class/agrammon/module/user/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ qx.Class.define('agrammon.module.user.Login', {
// content of the form elements if they appear inside a form AND
// the form has a name (firefox comes to mind).
var el = this.getContentElement();
var form = new qx.html.Element('form',null,{name: 'cbLoginform', autocomplete: 'on'});
var form = new qx.html.Element('form',null,{name: 'AgrammonLoginform', autocomplete: 'on'});
form.insertBefore(el);
el.insertInto(form);

Expand Down
2 changes: 1 addition & 1 deletion frontend/source/class/agrammon/ui/dialog/Error.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ qx.Class.define('agrammon.ui.dialog.Error', {
qx.event.message.Bus.subscribe('error', function(m) {
var data = m.getData();
that.setCaption(data[0]);
error.setLabel(data[1]);
error.setLabel(qx.locale.Manager.tr(data[1]));
if (data[2] == 'info') {
error.setIcon(null);
}
Expand Down
12 changes: 6 additions & 6 deletions frontend/source/translation/de.po
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ msgstr "Inkrementeller Filter auf den Datensatz-Namen"
msgid "Filter on dataset name"
msgstr "Filter auf den Datensatz Namen"

#: agrammon/ui/About.js
#: agrammon/module/dataset/DatasetCreate.js
msgid "Close"
msgstr "Schliessen"

Expand Down Expand Up @@ -1000,11 +1000,7 @@ msgstr "Fehler in der Kommunikation mit dem Server"

#: agrammon/module/user/Account.js
msgid "Password must have at least 8 characters."
msgstr ""

#: agrammon/module/user/Account.js
msgid "An activation link will be sent to you by eMail after pressing the button"
msgstr ""
msgstr "Das Passwort muss mindestens 8 Zeichen enthalten."

#: agrammon/module/user/SelfService.js
msgid "An activation link will be sent to you by eMail."
Expand All @@ -1020,4 +1016,8 @@ msgstr "Aktivierungslink geschickt an %1"

#: agrammon/module/user/SelfService.js
msgid "A confirmation link will be sent to you by eMail."
msgstr "Ein Bestätigungslink wird Ihnen per eMail zugesendet."

#: agrammon/module/user/Account.js
msgid "An activation link will be sent to you by eMail after pressing the button"
msgstr ""
14 changes: 10 additions & 4 deletions lib/Agrammon/DB/User.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,6 @@ class Agrammon::DB::User does Agrammon::DB {
sub get-password-key($username, $password) {
my $digest = sha1-hex($username ~ $password ~ $secret);
return $digest;
# only easily human readable characters
# return substr($digest ~~ tr/1/x/, 5, 6);
}

method get-account-key() {
Expand Down Expand Up @@ -186,8 +184,15 @@ class Agrammon::DB::User does Agrammon::DB {
$key = self.get-account-key();
$ret = $db.query(q:to/SQL/, $!username, $!firstname, $!lastname, $!organisation, %r<id>, $!password, $encrypt-key, $key );
INSERT INTO pers (pers_email, pers_first, pers_last,
pers_password, pers_org, pers_role, pers_newpassword, pers_newpassword_key)
VALUES ($1, $2, $3, gen_random_uuid(), $4, $5, encode(encrypt($6, $7, 'aes'), 'base64'), $8)
pers_password,
pers_org, pers_role,
pers_newpassword, pers_newpassword_key
)
VALUES ($1, $2, $3,
gen_random_uuid(), -- random password until activated
$4, $5,
encode(encrypt($6, $7, 'aes'), 'base64'), $8
)
RETURNING pers_id
SQL

Expand All @@ -212,6 +217,7 @@ class Agrammon::DB::User does Agrammon::DB {
SQL

$!username = $ret.value if $ret.rows;
note "Account activated for $!username";
}
self.load if $!username;
return self;
Expand Down
2 changes: 1 addition & 1 deletion lib/Agrammon/Web/Routes.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ sub application-routes(Agrammon::Web::Service $ws) {
}
CATCH {
.note;
when X::Agrammon::DB::User::InvalidPassword {
when X::Agrammon::DB::User::InvalidLogin {
forbidden 'application/json', %( error => .message );
}
}
Expand Down
5 changes: 4 additions & 1 deletion lib/Agrammon/Web/Service.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,10 @@ class Agrammon::Web::Service {
note "Account created for $email: activation key=$key";
if not %*ENV<AGRAMMON_TESTING> {
my $subject = "Agrammon account activation";
my $msg = "Click on the link to activate your Agrammon account: https://model.agrammon.ch/single/activate_account?key=$key";
# start link on new line to avoid . at beginning of second line
# of the encode string (seems to disappear in the received
# email) ... Fritz, 2025-01-14
my $msg = "Click on the link to activate your Agrammon account:\n\nhttps://model.agrammon.ch/single/activate_account?key=$key";
Agrammon::Email.new(
:to($email),
:from('[email protected]'),
Expand Down
3 changes: 1 addition & 2 deletions lib/Agrammon/Web/SessionUser.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class Agrammon::Web::SessionUser is Agrammon::DB::User does Cro::HTTP::Auth {
}
else {
$!logged-in = self.password-is-valid($username, $password);
die X::Agrammon::DB::User::InvalidPassword.new unless $!logged-in;

die X::Agrammon::DB::User::InvalidLogin.new unless $!logged-in;
}

self.set-username($username);
Expand Down
Loading