Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
ac998c2
feat: remove credential.js
rafaella-martino Aug 11, 2025
1532925
feat: remove ajax, rename controllers actions, use js alerts to displ…
rafaella-martino Aug 13, 2025
cb11999
feat: remove `message.js` as it is no longer used
rafaella-martino Aug 13, 2025
521b0c2
feat: remove unused js targets
rafaella-martino Aug 13, 2025
7bddc67
feat: replace `fetch` for `submit`, change `credential` param name to…
rafaella-martino Aug 13, 2025
871ab25
test: update test with renamed params
rafaella-martino Aug 14, 2025
cbf503e
feat: change `.then` for `await` for readability
rafaella-martino Aug 14, 2025
a990e01
feat: add permitted params in controllers
rafaella-martino Aug 14, 2025
bd72e31
feat: pass url as values, add token to session js controller
rafaella-martino Aug 15, 2025
6115812
feat: merge js controllers into one
rafaella-martino Aug 15, 2025
e19ef24
feat: change submit buttons, rename js controller variables
rafaella-martino Aug 15, 2025
9b46e85
fix: attend deprecation warning
rafaella-martino Aug 15, 2025
6fe61ca
Merge branch 'master' into rm--refactor_js
rafaella-martino Aug 15, 2025
6002921
style: use rails button helpers
rafaella-martino Aug 15, 2025
e93e3e8
feat: use `expect` to require params
rafaella-martino Aug 15, 2025
95b5664
feat: change `create_options` and `get_options` controller actions for
rafaella-martino Aug 18, 2025
331859e
fix: add space in css
rafaella-martino Aug 18, 2025
c42c9fc
rollback: use messenger.js to display error messages
rafaella-martino Aug 18, 2025
7a35c2c
feat: use `requestjs` gem
rafaella-martino Aug 18, 2025
81ad153
fix: Display layout instead of json when Webauthn Verification error
rafaella-martino Aug 18, 2025
c2753ed
feat: use render instead of redirect when request fails, use flash for
rafaella-martino Aug 19, 2025
1c92613
feat: Change variable names in JS controller
rafaella-martino Aug 19, 2025
5307cb1
refactor: move `request.js` import with the rest of the imports
rafaella-martino Sep 3, 2025
449c9cb
refactor: temporarily use `redirect` when `create` credential fails,
rafaella-martino Sep 3, 2025
e8b7ea3
refactor: enabling `submit` button when clicking `Cancel` with js
rafaella-martino Sep 10, 2025
9e58703
feat: clear not saved credential if there is an error
rafaella-martino Sep 10, 2025
672bcb1
Merge branch 'master' into rm--refactor_js
rafaella-martino Sep 11, 2025
b9edbe2
make rubocop happy
rafaella-martino Sep 11, 2025
23a316e
refactor: remove unnecessary cleanup when error updating credential
rafaella-martino Sep 11, 2025
55e10a6
rollback handling Webauthn Error exception
rafaella-martino Sep 11, 2025
e35488d
refactor: rollback to use json responses in case of errors
rafaella-martino Sep 12, 2025
3accfb1
refactor: leave controller response for next PR, rollback to respond
rafaella-martino Sep 12, 2025
18b76a5
change response message if registration success
rafaella-martino Sep 12, 2025
72e5f40
test: add new controller changes
rafaella-martino Sep 12, 2025
82a766f
stop displaying message
rafaella-martino Sep 12, 2025
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
21 changes: 11 additions & 10 deletions app/javascript/controllers/add_credential_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ export default class extends Controller {
}
});

optionsResponse.json().then((data) => {
try {
const data = await optionsResponse.json();
console.log(data);

if (optionsResponse.ok) {
navigator.credentials.create({ publicKey: PublicKeyCredential.parseCreationOptionsFromJSON(data) })
.then((credential) => {
console.log("Creating new public key credential...");
this.hiddenCredentialInputTarget.value = JSON.stringify(credential);
this.element.submit();
})
.catch((error) => alert(error));
console.log("Creating new public key credential...");

const credential = await navigator.credentials.create({ publicKey: PublicKeyCredential.parseCreationOptionsFromJSON(data) });
this.hiddenCredentialInputTarget.value = JSON.stringify(credential);
this.element.submit();
} else {
alert(data.errors?.[0] || "Sorry, something wrong happened.");
}
});
} catch (error) {
alert(error.message || error);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it okay to show the error if there's no message?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we could add a generic error message? Like the one we set before:

"Sorry, something wrong happened."

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good!

}
}
}
}
20 changes: 10 additions & 10 deletions app/javascript/controllers/new_registration_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ export default class extends Controller {
}
});

optionsResponse.json().then((data) => {
try {
const data = await optionsResponse.json();
console.log(data);

if (optionsResponse.ok && data.user) {
navigator.credentials.create({ publicKey: PublicKeyCredential.parseCreationOptionsFromJSON(data) })
.then((credential) => {
console.log("Creating new public key credential...");
this.hiddenCredentialInputTarget.value = JSON.stringify(credential);
this.element.submit();
})
.catch((error) => alert(error.message || error));
console.log("Creating new public key credential...");

const credential = await navigator.credentials.create({ publicKey: PublicKeyCredential.parseCreationOptionsFromJSON(data) });
this.hiddenCredentialInputTarget.value = JSON.stringify(credential);
this.element.submit();
} else {
alert(data.errors?.[0] || "Unknown error");
alert(data.errors?.[0] || "Sorry, something wrong happened.");
}
});
} catch (error) {
alert(error.message || error);
}
}
}
21 changes: 11 additions & 10 deletions app/javascript/controllers/new_session_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,21 @@ export default class extends Controller {
body: new FormData(this.element),
});

optionsResponse.json().then((data) => {
try {
const data = await optionsResponse.json();
console.log(data);

if (optionsResponse.ok) {
console.log(data);
console.log("Getting public key credential...");

navigator.credentials.get({ publicKey: PublicKeyCredential.parseRequestOptionsFromJSON(data) })
.then((credential) => {
console.log("Getting public key credential...");
this.hiddenCredentialInputTarget.value = JSON.stringify(credential);
this.element.submit();
})
.catch((error) => alert(error));
const credential = await navigator.credentials.get({ publicKey: PublicKeyCredential.parseRequestOptionsFromJSON(data) })
this.hiddenCredentialInputTarget.value = JSON.stringify(credential);
this.element.submit();
} else {
alert(data.errors?.[0] || "Sorry, something wrong happened.");
}
});
} catch (error) {
alert(error.message || error);
}
}
}