Thinkphp5_auth Authority authentication

Source: Internet
Author: User

1.Auth class File Introduction

2. Write a public class Authinfo, and all classes that have permission authentication inherit this public class Authinfo

Class AuthInfo extends controller{
protected function _initialize () {
if (!session ("? Intel_uid")) {
echo "<script>alert (' No landing! '); window.location.href = ' ". URL (' Index/index/index ')." '; </script> ";
}
$uid = Session (' Intel_uid ');
if ($uid ==1) {
return true;
}
$USERARR =db (' In_user ')->where (' id= '. $uid)->find ();
$access _id = $userArr [' role '];
$auth = new Auth ();
$name =request ()->module (). ' /'. Request ()->controller (). ' /'. Request ()->action ();
if (! $auth->check ($name, $access _id)) {
$this->error (' no permission! ');
}
}
}

Thinkphp5_auth Authority authentication

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.