Jump to content

Sign in system with access roles/permission


Marvin
 Share

Recommended Posts

Hi,

I'm still new at processwire, i want to ask, i was create a website with sign in system, but i want to add a access roles/permission for each user at my website. For now, i just can create a login user without any permission and the user data became as a pages in my processwire.

Here i attach my code for login

<?php 
  $note = $note2 = $hidden ="";

  if($input->get->id == "logout") {
    $session->remove('login_id');
  }

  if($input->post->submit) {
    $email = $sanitizer->email($input->post->email);
    $pass = $sanitizer->text($input->post->pass);
    $result = $pages->find("email=$email, text_1=$pass");

  if(!$email || !$pass) {
    $note = "Data belum lengkap";
  } else {
    if($result->count > 0) {
      $session->login_id = "$result";
      $hidden = "style = 'diplay:none'";
      $url=$pages->get("/files/")->httpUrl;
      header("Location:$url");
      die();
    } else {
      $note = "Akun tidak ditemukan";
    }
  }
}
?>

And this code for login form

<div class="frow-container">
  <div class="frow centered mt-50">
    <div class="col-md-1-3">
      <div class="box p-40 shadow-light">
        <h2 class="mb-20 text-center" <?=$hidden?>>Database Partitur<br>GII HIT</h2>
        <form method="post" <?=$hidden?>>
          <label>Username <input type="text" name="email"></label>
          <label>Password <input type="password" name="pass"></label>
          <input type="submit" name="submit" value="Masuk">
        </form>
        <p class="notif"><?=$note;?></p>
        <div class="text-center"><?=$note2;?></div>
      </div>
    </div>
  </div>
</div>

Just for remember, my user data now is a pages, and i cannot give any permission to user data.

Thank you very much for help.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...