alta usuarios
This commit is contained in:
20
lib/Dojo.pm
20
lib/Dojo.pm
@@ -38,7 +38,11 @@ use Dojo::Model::Users;
|
||||
$r->any('/json/candy/:command')->to('data#candy');
|
||||
$r->any('/candy')->to('home#candy');
|
||||
# =============================================================================
|
||||
|
||||
|
||||
# register user ===============================================================
|
||||
$r->any('/reg')->to('users#reg');
|
||||
# =============================================================================
|
||||
|
||||
# login guest =================================================================
|
||||
$r->any('/login')->to('users#login');
|
||||
$r->any('/logout')->to('users#logout');
|
||||
@@ -46,12 +50,16 @@ use Dojo::Model::Users;
|
||||
my $logged_in = $r->under('/')->to('users#is_logged');
|
||||
$logged_in->get('/radio')->to('home#radio');
|
||||
# =============================================================================
|
||||
|
||||
# login user grulla ===========================================================
|
||||
my $guestp = $r->under('/')->to('users#is_grulla');
|
||||
$guestp->any('/bcast')->to('home#bcast');
|
||||
# =============================================================================
|
||||
|
||||
# login user grulla ===========================================================
|
||||
# common grulla user
|
||||
my $user = $r->under('/')->to('users#is_grulla');
|
||||
$user->any('/ccast')->to('home#bcast');
|
||||
# personal
|
||||
my $guest = $r->under('/')->to('users#is_grulla_tmp');
|
||||
$guest->any('/bcast')->to('home#bcast');
|
||||
# =============================================================================
|
||||
|
||||
# admin =======================================================================
|
||||
my $admin = $r->under('/admin')->to('users#is_admin');
|
||||
$admin->any('')->to('home#admin');
|
||||
|
||||
@@ -1,23 +1,47 @@
|
||||
package Dojo::Controller::Users;
|
||||
use Mojo::Base 'Mojolicious::Controller';
|
||||
use Dojo::Support qw{ merge_hash load_module };
|
||||
use Dojo::Support 'log';
|
||||
use Email::Valid;
|
||||
|
||||
|
||||
sub login {
|
||||
sub reg{
|
||||
my $self=shift;
|
||||
my $switch=0;
|
||||
if ($self->param('request')){
|
||||
# 1=ok, 2=possible spam (simulate ok) 0=failed
|
||||
$switch = $self->dbg->createu(
|
||||
$self->param('user'),
|
||||
$self->param('uname'),
|
||||
$self->param('tel'),
|
||||
$self->param('mail'),
|
||||
$self->param('pass'),
|
||||
$self->param('passchk')
|
||||
)}
|
||||
$self->redirect_to("/login")
|
||||
unless $switch==0;
|
||||
$self->stash(layout=>"default");
|
||||
}
|
||||
|
||||
|
||||
sub login {
|
||||
my $self = shift;
|
||||
#falta si el usuario ya está registrado y llama a login.
|
||||
if (($self->session('ureq')//0) == 4){
|
||||
$self->stash( css=>["users/login/cssaForm.css"]);
|
||||
if (($self->session('ureq')//0) == 4){ #admin
|
||||
$self->stash(template=>'users/logina') ;
|
||||
$self->stash(layout=>"default");
|
||||
}
|
||||
elsif (($self->session('ureq')//0) == 2){
|
||||
$self->stash( css=>["users/login/cssuForm.css"]);
|
||||
$self->stash(template=>'users/loginu') ;
|
||||
elsif (($self->session('ureq')//0) == 1){ #invitado
|
||||
$self->stash(template=>'users/logini') ;
|
||||
$self->stash(layout=>"defaultContact");
|
||||
}
|
||||
elsif (($self->session('ureq')//0) == 2){ #usuario
|
||||
$self->session('tmpreq')//0 == 1?
|
||||
$self->stash(template=>'users/logint'): #temporal (grullas)
|
||||
$self->stash(template=>'users/loginu'); #registrado
|
||||
$self->stash(layout=>"defaultContact");
|
||||
}
|
||||
else{
|
||||
$self->stash( css=>["users/login/cssForm.css"]);
|
||||
$self->stash(template=>'users/loginu') ;
|
||||
$self->stash(layout=>"defaultContact");
|
||||
}
|
||||
my $user = $self->param('uname') // '';
|
||||
@@ -42,9 +66,15 @@ sub is_admin {
|
||||
sub is_grulla {
|
||||
my $self = shift;
|
||||
return 1 if (($self->session('pmid')//0)>=2);
|
||||
$self->session(ureq=>2,prev=>$self->url_for);
|
||||
$self->session(ureq=>2,tmpreq=>0,prev=>$self->url_for);
|
||||
$self->redirect_to('login');
|
||||
}
|
||||
sub is_grulla_tmp{
|
||||
my $self = shift;
|
||||
return 1 if (($self->session('pmid')//0)>=2);
|
||||
$self->session(ureq=>2,tmpreq=>1,prev=>$self->url_for);
|
||||
$self->redirect_to('login');
|
||||
}
|
||||
|
||||
sub logout {
|
||||
my $self = shift;
|
||||
|
||||
@@ -9,19 +9,44 @@ use Dojo::Conf;
|
||||
|
||||
|
||||
sub new { bless {}, shift }
|
||||
|
||||
sub grulla_pass{
|
||||
return
|
||||
_read( "select pass as gpass from usuario where nombre like 'grullas'")->[0]
|
||||
};
|
||||
sub ugrulla_pass{
|
||||
my($c,$p)=@_;
|
||||
_write("update usuario set pass= ? where nombre like 'grullas'",$p);
|
||||
sub createu{
|
||||
my ($c,$user,$uname,$tel,$mail,$pass,$passchk)=@_;
|
||||
my $ttel= $tel =~m/^$/ ? "0000000000" : $tel;
|
||||
$ttel =~ s/[^\+0-9]//g;
|
||||
if(
|
||||
$ttel =~m/\+?[0-9]{10,}/ &&
|
||||
Email::Valid->address($mail) &&
|
||||
$user =~m/[a-zA-Z]{3,25}/ &&
|
||||
$user !~m/\s/ && #mejora este
|
||||
$uname =~m/[a-zA-Z]{3,50}/ &&
|
||||
($pass eq $passchk)
|
||||
){
|
||||
if(
|
||||
$user =~m/\s|sex|http|webpage/ &&
|
||||
$uname =~m/sex|http|webpage/
|
||||
){ return 2} #possible spam
|
||||
# $ttel = $tel =~m/^$/? "null";
|
||||
if ( _write(
|
||||
"insert into usuario (usuario,nombre,telefono,correo,pass,permiso_id,ultima)
|
||||
values (?,?,?,?,?,2,now())",
|
||||
$user,$uname,$ttel,$mail,$pass) == 0){return 0;}
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub grulla_pass{
|
||||
return
|
||||
_read( "select pass as gpass from usuario where usuario like 'grullas'")->[0]
|
||||
};
|
||||
sub ugrulla_pass{
|
||||
my($c,$p)=@_;
|
||||
_write("update usuario set pass= ? where usuario like 'grullas'",$p);
|
||||
}
|
||||
|
||||
sub check {
|
||||
my ($self, $user, $pass) = @_;
|
||||
my $q="select permiso_id as pid from usuario where nombre = ? and pass=? ";
|
||||
my $q="select permiso_id as pid from usuario where usuario = ? and pass=? ";
|
||||
# | 0 | bloqueado |
|
||||
# | 1 | invitado |
|
||||
# | 2 | usuario |
|
||||
|
||||
66
public/users/login/formu.css
Executable file
66
public/users/login/formu.css
Executable file
@@ -0,0 +1,66 @@
|
||||
section.hero{
|
||||
height: calc(100vh - 50px);
|
||||
min-height:730px;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
background-size:cover;
|
||||
background-image:url("puerta.jpg");
|
||||
background-position: center center;
|
||||
|
||||
}
|
||||
section.reg{
|
||||
background:black;
|
||||
margin-top:30px;
|
||||
padding-top:10px;
|
||||
padding-bottom:10px;
|
||||
}
|
||||
section.reg:hover{
|
||||
background:#c22a39;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
article.login{
|
||||
background: rgba(33, 33, 33, 0.8);
|
||||
color:white;
|
||||
margin: auto 0px auto auto;
|
||||
padding: 1px 0px;
|
||||
text-align: center;
|
||||
min-width: 300px;
|
||||
max-width: 500px;
|
||||
width: 36%;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
article.login p{
|
||||
margin: 10vh auto 20px;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
article.login form{
|
||||
font-size:1.2em;
|
||||
width:80%;
|
||||
margin:auto;
|
||||
}
|
||||
|
||||
label{
|
||||
display:block;
|
||||
margin:10px 5px 15px 10px;
|
||||
}
|
||||
|
||||
form.login > input{
|
||||
width: 100%;
|
||||
height: 10vh;
|
||||
font-size: 1.3em;
|
||||
max-height: 50px;
|
||||
}
|
||||
|
||||
form.login > input#submit {
|
||||
display:block;
|
||||
margin:30px auto;
|
||||
width:200px;
|
||||
height:60px;
|
||||
}
|
||||
a,a:visited {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
53
public/users/reg/formr.css
Executable file
53
public/users/reg/formr.css
Executable file
@@ -0,0 +1,53 @@
|
||||
section.hero{
|
||||
height: calc(100vh - 25px);
|
||||
min-height:730px;
|
||||
background-repeat: no-repeat;
|
||||
background-attachment: fixed;
|
||||
background-size:cover;
|
||||
background-image:url("puerta.jpg");
|
||||
background-position: center center;
|
||||
}
|
||||
|
||||
article.reg{
|
||||
background: rgba(33, 33, 33, 0.8);
|
||||
color:white;
|
||||
margin: auto auto auto auto;
|
||||
padding: 1px 0px;
|
||||
text-align: center;
|
||||
min-width: 300px;
|
||||
max-width: 500px;
|
||||
width: 36%;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
article.reg p{
|
||||
margin: 10vh auto 20px;
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
article.reg form{
|
||||
font-size:1.2em;
|
||||
width:80%;
|
||||
margin:auto;
|
||||
}
|
||||
|
||||
label{
|
||||
display:block;
|
||||
text-align:left;
|
||||
margin:10px 5px 15px 10px;
|
||||
}
|
||||
|
||||
form.reg > input{
|
||||
width: 100%;
|
||||
height: 10vh;
|
||||
font-size: 1.3em;
|
||||
max-height: 50px;
|
||||
}
|
||||
|
||||
form.reg > input#submit {
|
||||
display:block;
|
||||
margin:30px auto;
|
||||
width:200px;
|
||||
height:60px;
|
||||
}
|
||||
|
||||
BIN
public/users/reg/puerta.jpg
Executable file
BIN
public/users/reg/puerta.jpg
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 196 KiB |
1
readme
1
readme
@@ -5,5 +5,6 @@ DBI
|
||||
Hash::Merge
|
||||
Path::Class
|
||||
DBD::Mysql
|
||||
Email::Valid
|
||||
djavu sans mono book 10
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
%stash css=>["/users/login/forma.css"];
|
||||
<section class="hero">
|
||||
<article class="login">
|
||||
<p>Admin</p>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
%stash css=>["/users/login/formi.css"];
|
||||
<section class="hero">
|
||||
<article class="login">
|
||||
<p>Área de alumnos</p>
|
||||
15
templates/users/logint.html.ep
Executable file
15
templates/users/logint.html.ep
Executable file
@@ -0,0 +1,15 @@
|
||||
%stash css=>["/users/login/formu.css"];
|
||||
<section class="hero">
|
||||
<article class="login">
|
||||
<p>Bienvenido</p>
|
||||
<form class="login" action="" method="post">
|
||||
<label class="name" >Nombre:</label>
|
||||
<input class="name" type="text" name="uname" value="grullas">
|
||||
<label>Nombre para el chat:</label>
|
||||
<input type="text" size="20" name="nick" value=""/>
|
||||
<label class="pass">Contraseña:</label>
|
||||
<input class="pass" type="password" size="15" name="pass" value=""/>
|
||||
<input type="submit" id="submit" value="Entrar"/>
|
||||
</form>
|
||||
</article>
|
||||
</section>
|
||||
@@ -1,9 +1,16 @@
|
||||
%stash css=>["/users/login/formu.css"];
|
||||
<section class="hero">
|
||||
<article class="login">
|
||||
<section class="reg">
|
||||
<a href="/reg" class="reg">
|
||||
<h2 class="reg small">¿No te has registrado?</h2>
|
||||
<h2 class="reg big">¡Registrate!</h2>
|
||||
</a>
|
||||
</section>
|
||||
<p>Bienvenido</p>
|
||||
<form class="login" action="" method="post">
|
||||
<label class="name" >Nombre:</label>
|
||||
<input class="name" type="text" name="uname" value="grullas">
|
||||
<input class="name" type="text" name="uname" value="">
|
||||
<label>Nombre para el chat:</label>
|
||||
<input type="text" size="20" name="nick" value=""/>
|
||||
<label class="pass">Contraseña:</label>
|
||||
|
||||
22
templates/users/reg.html.ep
Normal file
22
templates/users/reg.html.ep
Normal file
@@ -0,0 +1,22 @@
|
||||
%stash css=>["/users/reg/formr.css"];
|
||||
<section class="hero">
|
||||
<article class="reg">
|
||||
<p>Registro Vuelo de Grulla</p>
|
||||
<form class="reg" action="" method="post">
|
||||
<label>Elige un nombre de usuario:</label>
|
||||
<input type="text" size="20" name="user" value="<%= $self->param('user')//''; %>" required/>
|
||||
<label>Nombre completo:</label>
|
||||
<input type="text" name="uname" value="<%= $self->param('uname')//''; %>" required/>
|
||||
<label>Teléfono de contacto:</label>
|
||||
<input type="tel" name="tel" value="<%= $self->param('tel')//''; %>"/>
|
||||
<label>Correo electrónico:</label>
|
||||
<input type="email" name="mail" value="<%= $self->param('mail')//'';%>" required/>
|
||||
<label class="pass">Contraseña:</label>
|
||||
<input class="pass" type="password" size="15" name="pass" value="" required/>
|
||||
<label class="pass">Repite la contraseña:</label>
|
||||
<input class="pass" type="password" size="15" name="passchk" value="" required/>
|
||||
<input type="hidden" name="request" value=1>
|
||||
<input type="submit" id="submit" value="Alta"/>
|
||||
</form>
|
||||
<article>
|
||||
</section>
|
||||
Reference in New Issue
Block a user