I am beginner working with electron js I have created my first app in electron js and I am trying to do login authentication using java rest API since I am not knowing how to do that I have done completed hard coded authentication.When Login gets success how to do routing to new screen such as dashboard
const { app, BrowserWindow } = require('electron');
const path = require('path');
const createWindow = () => {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
});
mainWindow.loadFile(path.join(__dirname, 'index.html'));
};
app.on('ready', createWindow);
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<form>
<fieldset>
<legend>Login:</legend>
<label for="username">UserName</label>
<input type="text" id="uname" name="fname"><br><br>
<label for="password">Password:</label>
<input type="password" id="pwd" name="lname"><br><br>
<input type="submit" value="Login" id="sbtn">
</fieldset>
</form>
</body>
<script>
document.querySelector('#sbtn').addEventListener('click', () => {
let userName=document.getElementById("uname").value;
let pwd=document.getElementById("pwd").value;
if(userName=="abc" && pwd=="123"){
alert("Login sucess");
}else{
alert("Failed to login")
}
})
</script>
</html>