-
-
19 Dec 2021 02:26:57 UTC
- Distribution: Yancy
- Module version: 1.088
- Source (raw)
- Browse (raw)
- Changes
- Homepage
- How to Contribute
- Repository
- Issues (17)
- Testers (48 / 0 / 2)
- Kwalitee
Bus factor: 1- 77.17% Coverage
- License: perl_5
- Perl: v5.16.0
- Activity
24 month- Tools
- Download (1.34MB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
and 11 contributors-
Boris Däppen
-
Ed J
-
Erik Johansen
-
flash548
-
Josh Rabinowitz
-
Mohammad S Anwar
-
Pavel Serikov
-
Rajesh Mallah
-
Roy Storey
-
William Lindley
-
Wojtek Bażant
NAME
Yancy::Plugin::Auth::Role::RequireUser - Add authorization based on user attributes
VERSION
version 1.088
SYNOPSIS
use Mojolicious::Lite; plugin Yancy => ...; # Require any user my $require_user = app->yancy->auth->require_user; my $user = app->routes->under( '/user', $require_user ); # Require a user with the `is_admin` field set to true my $require_admin = app->yancy->auth->require_user( { is_admin => 1 } ); my $admin = app->routes->under( '/admin', $require_admin );
DESCRIPTION
Note: This module is
EXPERIMENTAL
and its API may change before Yancy v2.000 is released.This plugin adds a simple authorization method to your site. All default Yancy auth plugins use this role to provide the
yancy.auth.require_user
helper.METHODS
require_user
my $subref = $c->yancy->auth->require_user( \%match );
Build a callback to validate there is a logged-in user, and optionally that the current user has certain fields set.
\%match
is optional and is a SQL::Abstract where clause matched with "match" in Yancy::Util.# Ensure the user is logged-in my $user_cb = $app->yancy->auth->require_user; my $user_only = $app->routes->under( $user_cb ); # Ensure the user's "is_admin" field is set to 1 my $admin_cb = $app->yancy->auth->require_user( { is_admin => 1 } ); my $admin_only = $app->routes->under( $admin_cb );
SEE ALSO
AUTHOR
Doug Bell <preaction@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2021 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Module Install Instructions
To install Yancy, copy and paste the appropriate command in to your terminal.
cpanm Yancy
perl -MCPAN -e shell install Yancy
For more information on module installation, please visit the detailed CPAN module installation guide.