Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save davidystephenson/d2d7febe152c84f36e7dc26d8b1ca835 to your computer and use it in GitHub Desktop.

Select an option

Save davidystephenson/d2d7febe152c84f36e7dc26d8b1ca835 to your computer and use it in GitHub Desktop.
const message = document.getElementById('message')
const form = document.getElementById('sign-in')
const username = document.getElementById('userName')
const password = document.getElementById('password')
form.addEventListener('submit', (event) => {
event.preventDefault()
const localUser = localStorage.getItem('user')
console.log('localUser', localUser)
console.log('localUser.username', localUser.username)
const user = JSON.parse(localUser)
console.log('user', user)
console.log('user.username', user.username)
if (username.value !== user.username || password.value !== user.password) {
message.innerHTML = 'Register before sign in'
return
}
sessionStorage.setItem('login', true)
window.location.href = './html/index.html'
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment