Answer the question
In order to leave comments, you need to log in
How to make complex access rights?
I want to make the access rights that the user will constantly change, i.e. not just admin, user, etc. For example, we have a user. He has access to a course. And this course is only the first lesson. And until he passes the first lesson, others will not be available to him. Also, the administrator, for example, can randomly open one of the lessons. How can this be implemented?
Answer the question
In order to leave comments, you need to log in
All logic in Angular 2 is done through service classes, in which you can perform checks of any complexity. It is enough to perform 3 simple steps:
1. For example, in user.service.ts we will add information about the authorized user.
2. Let's create the AuthGuard service, which will be responsible for authorization. It must implement the CanActivate interface
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private userService: UserService) {}
canActivate(route: ActivatedRouteSnapshot, state:RouterStateSnapshot): Promise<boolean>|boolean {
return this.userService.isAuth;
}
}
{
path: 'logout',
component: LogoutComponent,
canActivate: [AuthGuard]
},
{
path: 'login',
component: LoginComponent,
canActivate: [GuestGuard]
},
You first use mysqli_query(), and then mysql_fetch_array(), that is, in the first case, you use the mysql php extension, and in the second, mysqli. You already decide. To fix the error add the letter i to get mysql i _fetch_array.
As a result, the code will look like:
<?php
$res = mysqli_query($connection, "SELECT videos.* FROM video_category join category ON category.id = video_category.category_id JOIN videos ON videos.id = video_category.video_id");
$video = array();
while($row = mysqli_fetch_array($res)){
$videos[] = $row;
}
?>
Your $connection variable is not declared anywhere, as you can see from this code. In general, you gave him an object instead of a resource ($connection)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question