The UserAuth class handles user authentication actions such as sign-in, sign-out, sign-up, and OTP submission. It can also be extended or modified for simple form submissions.
- Clone the repository or download the file containing the UserAuth class.
- Include the script in your project.
To use the UserAuth class, create an instance of the class by providing the authentication method and the form element's identifier.
import UserAuth from './path-to-file/UserAuth.js';
const auth = new UserAuth('signin', 'loginForm');
constructor(method, elementIdentifier)
Creates an instance of UserAuth.
method
: The authentication method (e.g., 'signin', 'signout', 'signup', 'otp_submit', 'otp_resend').elementIdentifier
: The ID of the form element to bind event listeners to.
<form id="loginForm" action="/login">
<input type="email" name="email" required>
<input type="password" name="password" required>
<button type="submit">Sign In</button>
<div class="error"></div>
</form>
<script type="module">
import UserAuth from './path-to-file/UserAuth.js';
const auth = new UserAuth('signin', 'loginForm');
</script>
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is licensed under the MIT License - see the LICENSE file for details.