Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
2.1 kB
1
Indexable
Never
//signup.js

const taskForm2 = document.querySelector('#taskForm2')
const Username1 = document.querySelector('#Username1')
const Password1 = document.querySelector('#Password1')
const Email = document.querySelector('#Email')
const CPassword = document.querySelector('#CPassword1')
const { ipcRenderer } = require('electron')
let users=[];

taskForm2.addEventListener("submit",async e=>{
    e.preventDefault();
    const user={
      email:Email.value,
  name:Username1.value,
  pass:Password1.value 
    }
    if(CPassword.value!==Password1.value){
      ipcRenderer.invoke('not-new', user).then(()=> console.log('new user entered')).catch((err)=> console.error('Error'))
    }else{
      ipcRenderer.invoke('new', user).then(()=> console.log('new user entered')).catch((err)=> console.error('Error'))
     
    }
    taskForm2.reset()
  })

  ipcRenderer.on("new-user-created", (e, arg) => {
    console.log(arg);
    const taskSaved = JSON.parse(arg);
    users.push(taskSaved);
   
    
  });
    
//signup.html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Security-Policy" content="default-src 'self'; script-src 'self';">
   
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="ui/style.css" />
  
  <title>SignUpForm</title>
</head>
<body>
  <h1>Sign Up</h1>
    
    <form id="taskForm2">
     
      <br>
      
      <input type="text" id="Email" placeholder="Email" autofocus />
      <br>
     
      <input id="Username1" placeholder="Username" autofocus />
      <br>
   
      <input type="text" id="Password1" placeholder="Password" autofocus/>
      <br>
     
      <input type="text" id="CPassword1" placeholder="Confirm Password" autofocus />
      <br>
      <input type="Submit" placeholder="SAVE"/></button>
    </form>
    
  </div>
  <p class="para-2">
    <br>
    Already have an account? <a href="index.html">Login here</a>
    <script  src="signup.js"></script>
  </p>
</body>
</html>