Trigger a 'change password' notification using Javascript

Issue:

I am currently working on developing a web application that includes a password change functionality without the use of form submission.

The process I have in mind is as follows:

  1. Show a Bootstrap modal pop-up
  2. User enters new password
  3. Upon clicking 'Ok' in the modal, a fetch request will be triggered to update the database
  4. Once the API confirms, somehow trigger the password manager dialogue in browsers like Firefox or Chrome

To clarify: The browser password manager dialogue is the popup that appears when submitting a login form.

View an example of the popup here
(source: )

Technology Stack:

For reference, my technology stack consists of:

  • Vue.js (without additional plugins except VueX)
  • Bootstrap (including all JS files)
Code Snippet
<h1>Traditional Form Submission: (Functional)</h1>
<form action="/login" method="post">
    <input type="text" name="username" id="">
    <input type="password" name="password" id="">
    <button type="submit">Submit</button>
</form>

<h1>My Approach (Simplified):</h1>
<p>Please enter your new password</p>
<input type="text" v-model="password">

<!-- Modal -->
<div class="modal">
    <p>Kindly provide your old password for verification</p>
    <input type="text" v-model="old">
    <button @click="updatePassword">Update</button>
</div>
//Vue function
function updatePassword(){
    // Calling the fetch API to update the password
    callAPI( '/api/update_password', { old:this.old, password:this.password } )
}
Alternative Approaches Considered:

I have explored using a hidden form directed towards a non-functional endpoint that gets submitted via JavaScript.

Reasons against this approach:
  1. Feels like a workaround solution
  2. Prevents unnecessary network requests
  3. Creating and removing DOM elements purely for JavaScript purposes may not be considered best practice
  4. Wondering if there's an existing API solution that I might be overlooking

Thank you in anticipation!
- Stevetec

Answer №1

The web browser is designed to prevent forcing actions onto users. Users have the ability to disable certain features locally, and allowing websites to force security-related popups could potentially lead to harmful attacks.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

NodeJS Socket not transmitting file after connection with client

Having scoured the depths of various resources, including SO and Google, I have hit a roadblock. I am struggling to understand why the socket is failing to capture the uploaded file via the form; it simply stops after connecting. When I check the console, ...

Receiving error messages about missing images in my React project

I am new to programming and I have encountered an issue while running my React project. When I use the command npm start, I noticed that some image resources are not being packaged properly, resulting in certain images disappearing when the website is run ...

Changing the color of HTML text based on a variable in Vue JS can be achieved by altering the CSS styles dynamically

I have developed a website that shows values with a set threshold. I now want to change the color of the values when they exceed the threshold, but I am unsure of how to proceed. I want to display consultation.indicateurs.TRS in red when it exceeds the va ...

Integrating TypeScript into an established create-react-app project

Struggling to integrate TypeScript into an existing create-react-app? I've always added it at the beginning of a project using create-react-app my-app --scripts-version=react-scripts-ts, but that's not working this time. The only "solution" I co ...

Featherlight is experiencing issues with running Ajax requests

I'm currently working on integrating an ajax photo uploading script into a Featherlight lightbox, but I'm running into issues! If anyone could help me figure out what's going wrong, that would be greatly appreciated. I've already includ ...

A guide on implementing Google reCAPTCHA in a Nuxt.js website

Trying to implement the recaptcha-module from nuxt-community in my Nuxt project but struggling with verifying if the user has passed the check. The documentation and example provided are not clear enough for me (https://github.com/nuxt-community/recaptch ...

Displaying a pair of values using a single noUISlider

I'm trying to achieve something unique with a noUIslider range by outputting two values. While I've managed to display the same value twice using examples from the noUIslider documentation, my goal is to have one of the outputs show a value that ...

Utilizing nested array object values in ReactJS mappings

My JSON API is set up to provide a data structure for a single record, with an array of associations nested within the record. An example of the response from the api looks like this: { "name":"foo", "bars":[ { "name":"bar1" ...

What is the designated color for highlighting an option in Next.js?

This is my first time working on a Next.js project and I see an unfamiliar option. Which selection should I choose? I plan to use JavaScript for the Next.js project, not TypeScript. Just need to figure out which option is currently selected so I can pro ...

Trouble with minified scripts on a particular server

Apologies if this has already been addressed, but I've been searching for a solution for hours. I created a basic website that works perfectly on my own hosting. However, when I transfer it to new hosting (same company, same package, different server ...

"Passing an Empty String as Input in a NodeJS Application

app.post('/register',function(req,res){ var user=req.body.username; var pass=req.body.password; var foundUser = new Boolean(false); for(var i=0;i<values.length;i++){ //if((JSON.stringify(values[i].usernames).toLowerCase==JSON. ...

React is unable to maintain the list during route transitions

I have been working on a project where I input user information into a form and upon submission, it displays the data in a table on the same page. Everything works fine initially, but when I navigate back to the form page after visiting the Home page, the ...

After logging in, the initial API request is unauthorized and requires a page refresh for access (Using Laravel Sanctum and VueJS)

I've been grappling with this 401 issue for quite some time now. Even after successfully logging in and obtaining the token, I continue to encounter a 401 exception on the initial page load. Strangely, the error disappears upon refreshing the page. It ...

Attempting to remove the current click event listener and add a new event listener

I am attempting to remove the click event binding and replace it with another click event after the button has been clicked once. <small id="selectall_agriculture" onclick="refineSearch.testing('agriculture')">(select all)</small> O ...

The MongoClient object does not possess the 'open' method

I recently started working on a project using Node.js, Express.js, and MongoDB. I've encountered some issues while trying to set up the database configuration. Below is a snippet of code from my index.js file: var http = require('http'), ...

The prolonged action is causing the renderer process to become locked

I am currently experiencing an issue with a function that is triggered by changes in a vue-select component within my component template. <v-select v-model="model" :options="eventList" :placeholder="currentEventTitle" v-on:input="selectedEvent" ...

The ajax success() function is failing to function properly when attempting to make a call

The button's onClick() event is not navigating anywhere. There seems to be an issue with the success() function of the ajax call. Unfortunately, I am new to this and unable to pinpoint the problem. var currentAuthor=""; var currentQuote=""; $(documen ...

Loading content synchronously

Could you assist me in finding a solution to synchronize the loading of pages and elements? Currently, my code looks like this: $(Element).load(File); ... other commands... window.onload = function () { Update_Elements(Class, Content); } Everything ...

Generate a unique ID each time the page is loaded or refreshed

I'm currently working on a function that will display a unique ID or a different video each time the page is loaded or refreshed. My main objective is to design a splash intro popup that features a <section> with a full-screen YouTube video bac ...

Creating responsive tables in ag-grid-vue with VueJS to adjust column widths and fit the table to any screen size

I am currently utilizing Ag-grid to present a table, and my goal is to ensure that the table is responsive. My aim is to have the entire table or columns adjust their width according to the screen size: If the screen width is below 500px, then I want the ...