| 1 | package Rapi::Blog::CatalystApp; | ||
| 2 | use Moose::Role; | ||
| 3 | use namespace::autoclean; | ||
| 4 | |||
| 5 | # ABSTRACT: Common Catalyst plugin loaded on all Rapi::Blog apps | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | use RapidApp::Util qw(:all); | ||
| 11 | |||
| 12 | |||
| 13 | around 'authenticate' => sub { | ||
| 14 | my ($orig, $c, @args) = @_; | ||
| 15 | |||
| 16 | my $opt = $args[0]; | ||
| 17 | if((ref($opt)||'') eq 'HASH' && $opt->{username}) { | ||
| 18 | my $User = $c->model('DB::User')->search_rs({ 'me.username' => $opt->{username} })->first; | ||
| 19 | if ($User && $User->has_column('disabled') && $User->disabled) { | ||
| 20 | $c->log->debug("Denied login for '$opt->{username}' -- account disabled"); | ||
| 21 | return 0; | ||
| 22 | } | ||
| 23 | } | ||
| 24 | |||
| 25 | $c->$orig(@args); | ||
| 26 | |||
| 27 | }; | ||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | 1; |