Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Farol_antigo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PET Computação
Farol_antigo
Commits
54a313fd
Commit
54a313fd
authored
9 years ago
by
Vytor Calixto
Browse files
Options
Downloads
Patches
Plain Diff
Adicionado como alterar a senha
parent
606c4500
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Reimplementação em NodeJS
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/views/conta.ejs
+14
-0
14 additions, 0 deletions
client/views/conta.ejs
libs/routes/routes.js
+65
-8
65 additions, 8 deletions
libs/routes/routes.js
with
79 additions
and
8 deletions
client/views/conta.ejs
+
14
−
0
View file @
54a313fd
...
...
@@ -3,6 +3,12 @@
<
%
include
partials
/
head
%
>
<body>
<
%
include
partials
/
basic-header
%
>
<
%
if
(
message.length
>
0) { message = JSON.parse(message); %>
<script>
swal
(
'
<%= message.title %>
'
,
'
<%= message.message %>
'
,
'
<%= message.type %>
'
);
</script>
<
%
}
%
>
<section
class=
"card margin clearfix"
>
<h2><
%=
user.nome
%
>
- @
<
%=
user.username
%
></h2>
...
...
@@ -22,6 +28,14 @@
</p>
<
%
}
%
>
<p>
Membro desde
<
%=
user.criado
%
></p>
<form
method=
"post"
>
<input
type=
"password"
placeholder=
"Senha atual"
name=
"oldpassword"
required
>
<br>
<input
type=
"password"
placeholder=
"Nova senha"
name=
"newpassword"
required
>
<br>
<button
class=
"button normal"
type=
"submit"
>
Alterar senha
</button>
<br>
</form>
</section>
<
%
include
partials
/
footer
%
>
...
...
This diff is collapsed.
Click to expand it.
libs/routes/routes.js
+
65
−
8
View file @
54a313fd
...
...
@@ -38,6 +38,8 @@ var Materia = require(libs + 'model/materia')
var
Professor
=
require
(
libs
+
'
model/professor
'
)
var
role
=
require
(
libs
+
'
role
'
)
var
log
=
require
(
libs
+
'
log
'
)(
module
)
router
.
get
(
'
/
'
,
function
(
req
,
res
)
{
var
user
=
req
.
user
if
(
user
)
{
...
...
@@ -79,7 +81,7 @@ router.get('/verify/:token', function(req, res) {
var
ok
=
true
VerificationToken
.
findOne
({
token
:
token
},
function
(
err
,
vToken
)
{
if
(
err
)
{
console
.
log
(
err
)
log
.
error
(
err
)
req
.
flash
(
'
verifyMessage
'
,
'
A verificação falhou. Entre em contato com um administrador através do e-mail pet@inf.ufpr.br
'
)
ok
=
false
}
...
...
@@ -87,7 +89,7 @@ router.get('/verify/:token', function(req, res) {
usuario
.
verificado
=
true
usuario
.
save
(
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
)
log
.
error
(
err
)
ok
=
false
req
.
flash
(
'
verifyMessage
'
,
'
A verificação falhou. Entre em contato com um administrador através do e-mail pet@inf.ufpr.br
'
)
}
...
...
@@ -98,7 +100,62 @@ router.get('/verify/:token', function(req, res) {
})
router
.
get
(
'
/conta
'
,
role
.
isLoggedIn
(),
function
(
req
,
res
)
{
res
.
render
(
'
conta
'
,
{
user
:
req
.
user
})
res
.
render
(
'
conta
'
,
{
user
:
req
.
user
,
message
:
req
.
flash
(
'
updatePassword
'
)})
})
router
.
post
(
'
/conta
'
,
role
.
isLoggedIn
(),
function
(
req
,
res
)
{
Usuario
.
findOne
({
_id
:
req
.
user
.
_id
},
function
(
err
,
usuario
)
{
if
(
!
usuario
)
{
// TODO: 404
req
.
flash
(
'
updatePassword
'
,
JSON
.
stringify
({
title
:
'
Ops!
'
,
message
:
'
Não foi possível alterar sua senha.
'
+
err
,
type
:
'
error
'
}))
res
.
redirect
(
'
/conta
'
)
}
if
(
!
err
)
{
if
(
usuario
.
checkPassword
(
req
.
body
.
oldpassword
))
{
usuario
.
password
=
req
.
body
.
newpassword
usuario
.
save
(
function
(
err
)
{
if
(
!
err
)
{
req
.
flash
(
'
updatePassword
'
,
JSON
.
stringify
({
title
:
'
Alterada!
'
,
message
:
'
Sua senha foi alterada com sucesso.
'
,
type
:
'
success
'
}))
res
.
redirect
(
'
/conta
'
)
}
else
{
//TODO: 500
req
.
flash
(
'
updatePassword
'
,
JSON
.
stringify
({
title
:
'
Ops!
'
,
message
:
'
Não foi possível alterar sua senha.
'
+
err
,
type
:
'
error
'
}))
log
.
error
(
err
)
res
.
redirect
(
'
/conta
'
)
}
})
}
else
{
req
.
flash
(
'
updatePassword
'
,
JSON
.
stringify
({
title
:
'
Ops!
'
,
message
:
'
Não foi possível alterar sua senha.
'
+
err
,
type
:
'
error
'
}))
res
.
redirect
(
'
/conta
'
)
}
}
else
{
log
.
error
(
err
)
//TODO: 500
req
.
flash
(
'
updatePassword
'
,
JSON
.
stringify
({
title
:
'
Ops!
'
,
message
:
'
Não foi possível alterar sua senha.
'
+
err
,
type
:
'
error
'
}))
res
.
redirect
(
'
/conta
'
)
}
})
})
router
.
get
(
'
/upload
'
,
role
.
isLoggedIn
(),
function
(
req
,
res
)
{
...
...
@@ -123,8 +180,8 @@ router.post('/upload', role.isLoggedIn(), role.isVerificado(), upload.array('arq
if
(
!
err
)
{
Professor
.
find
({
nome
:
req
.
body
.
professor
}).
exec
(
function
(
err
,
professor
)
{
if
(
!
err
)
{
console
.
lo
g
(
materia
)
console
.
lo
g
(
professor
)
log
.
debu
g
(
materia
)
log
.
debu
g
(
professor
)
for
(
var
f
in
req
.
files
)
{
file
=
req
.
files
[
f
]
var
arquivo
=
new
Arquivo
({
...
...
@@ -145,7 +202,7 @@ router.post('/upload', role.isLoggedIn(), role.isVerificado(), upload.array('arq
arquivo
.
save
(
function
(
err
)
{
if
(
!
err
)
{
console
.
lo
g
(
arquivo
)
log
.
debu
g
(
arquivo
)
res
.
render
(
'
uploadDetails
'
,
{
user
:
req
.
user
,
arquivo
:
arquivo
,
materia
:
materia
[
0
].
nome
,
professor
:
professor
[
0
].
nome
})
}
else
{
if
(
err
.
name
===
'
ValidationError
'
)
{
...
...
@@ -157,7 +214,7 @@ router.post('/upload', role.isLoggedIn(), role.isVerificado(), upload.array('arq
}
console
.
log
(
'
Internal error(%d): %s
'
,
res
.
statusCode
,
err
.
message
)
fs
.
unlink
(
file
.
path
,
function
()
{
if
(
err
)
console
.
log
(
err
)
if
(
err
)
log
.
error
(
err
)
})
}
})
...
...
@@ -175,7 +232,7 @@ router.get('/upload/cancel/:id', role.isLoggedIn(), role.isVerificado(), functio
return
res
.
json
({
error
:
'
Not found
'
})
}
fs
.
unlink
(
arquivo
.
arquivo
,
function
()
{
if
(
err
)
console
.
log
(
err
)
if
(
err
)
log
.
error
(
err
)
})
req
.
flash
(
'
uploadMessage
'
,
JSON
.
stringify
({
title
:
'
Cancelado
'
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment