User login / registration for electron app

Hi I have built a user registration / login site using node.js express and mysql

using this tutorial Basic Login System with Node.js, Express, and MySQL

is it possible to create an electron desktop app using my current code - I want to be able to use the mysql database for my data back-end for the app and if possible add an admin area where I can manage users.

or is there another method I could use, without using a third party service.

1 Like

Ok so I have managed to get the app to load, do I need to change the / to ./ in my code for it to work in electron, should I move my app.js to my views folder?

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Login</title>
		<link rel="stylesheet" href="../static/style.css">
		<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.1/css/all.css">
		<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
		<script src="../script.js"></script>
	</head>
	<body>
		<div class="login">
			<h1>Login</h1>
			<div class="links">
				<a href="./index.html" class="active">Login</a>
				<a href="./register.html">Register</a>
			</div>
			<form class="ajax-form" action="./" method="post">
				<label for="username">
					<i class="fas fa-user"></i>
				</label>
				<input type="text" name="username" placeholder="Username" id="username" required>
				<label for="password">
					<i class="fas fa-lock"></i>
				</label>
				<input type="password" name="password" placeholder="Password" id="password" required>
				<label id="rememberme">
					<input type="checkbox" name="rememberme">Remember me
				</label>
				<div class="msg">{{ msg }}</div>
				<input type="submit" value="Login">
			</form>
		</div>
	</body>
</html>

This is not working as expected I think its because I am trying to use an ajay-form function

$(document).ready(function() {

    if ($(".ajax-form").length) {

        $(".ajax-form").submit(function(event) {

            var form = $(this);

            var url = form.attr('action');

            $.ajax({

                type: "POST",

                url: url,

                data: form.serialize(),

                success: function(data) {

                    if (data == "Success") {

                        window.location.href = "home";

                    } else {

                        $(".msg").text(data);

                    }

                }

            });

            event.preventDefault();

        });

    }

});

this is the console error I get