Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Nextcloud
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TeDomum
Nextcloud
Commits
6bdefef3
Commit
6bdefef3
authored
12 years ago
by
Frank Karlitschek
Browse files
Options
Downloads
Patches
Plain Diff
csrf protection
parent
12779621
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/lostpassword/index.php
+13
-6
13 additions, 6 deletions
core/lostpassword/index.php
core/lostpassword/templates/lostpassword.php
+1
-0
1 addition, 0 deletions
core/lostpassword/templates/lostpassword.php
with
14 additions
and
6 deletions
core/lostpassword/index.php
+
13
−
6
View file @
6bdefef3
...
@@ -9,13 +9,14 @@
...
@@ -9,13 +9,14 @@
$RUNTIME_NOAPPS
=
TRUE
;
//no apps
$RUNTIME_NOAPPS
=
TRUE
;
//no apps
require_once
(
'../../lib/base.php'
);
require_once
(
'../../lib/base.php'
);
// Someone lost their password:
// Someone lost their password:
if
(
isset
(
$_POST
[
'user'
]))
{
if
(
isset
(
$_POST
[
'user'
]))
{
if
(
OC_User
::
userExists
(
$_POST
[
'user'
]))
{
if
(
OC_User
::
userExists
(
$_POST
[
'user'
]))
{
$token
=
sha1
(
$_POST
[
'user'
]
.
md5
(
uniqid
(
rand
(),
true
)));
$token
=
sha1
(
$_POST
[
'user'
]
.
md5
(
uniqid
(
rand
(),
true
)));
OC_Preferences
::
setValue
(
$_POST
[
'user'
],
'owncloud'
,
'lostpassword'
,
$token
);
OC_Preferences
::
setValue
(
$_POST
[
'user'
],
'owncloud'
,
'lostpassword'
,
$token
);
$email
=
OC_Preferences
::
getValue
(
$_POST
[
'user'
],
'settings'
,
'email'
,
''
);
$email
=
OC_Preferences
::
getValue
(
$_POST
[
'user'
],
'settings'
,
'email'
,
''
);
if
(
!
empty
(
$email
))
{
if
(
!
empty
(
$email
)
and
isset
(
$_POST
[
'sectoken'
])
and
isset
(
$_SESSION
[
'sectoken'
])
and
(
$_POST
[
'sectoken'
]
==
$_SESSION
[
'sectoken'
])
)
{
$link
=
OC_Helper
::
linkToAbsolute
(
'core/lostpassword'
,
'resetpassword.php'
)
.
'?user='
.
$_POST
[
'user'
]
.
'&token='
.
$token
;
$link
=
OC_Helper
::
linkToAbsolute
(
'core/lostpassword'
,
'resetpassword.php'
)
.
'?user='
.
$_POST
[
'user'
]
.
'&token='
.
$token
;
$tmpl
=
new
OC_Template
(
'core/lostpassword'
,
'email'
);
$tmpl
=
new
OC_Template
(
'core/lostpassword'
,
'email'
);
$tmpl
->
assign
(
'link'
,
$link
);
$tmpl
->
assign
(
'link'
,
$link
);
...
@@ -23,14 +24,20 @@ if (isset($_POST['user'])) {
...
@@ -23,14 +24,20 @@ if (isset($_POST['user'])) {
$l
=
OC_L10N
::
get
(
'core'
);
$l
=
OC_L10N
::
get
(
'core'
);
$from
=
'lostpassword-noreply@'
.
$_SERVER
[
'HTTP_HOST'
];
$from
=
'lostpassword-noreply@'
.
$_SERVER
[
'HTTP_HOST'
];
$r
=
mail
(
$email
,
$l
->
t
(
'Owncloud password reset'
),
$msg
,
'From:'
.
$from
);
$r
=
mail
(
$email
,
$l
->
t
(
'Owncloud password reset'
),
$msg
,
'From:'
.
$from
);
//if($r==false) echo('error'); else echo('works!!!!!!!
');
OC_MAIL
::
send
(
$email
,
$_POST
[
'user'
],
$l
->
t
(
'ownCloud password reset'
),
$msg
,
$from
,
'ownCloud
'
);
OC_MAIL
::
send
(
$email
,
$_POST
[
'user'
],
$l
->
t
(
'Owncloud password reset'
),
$msg
,
$from
,
'ownCloud
'
);
echo
(
'sent
'
);
}
}
OC_Template
::
printGuestPage
(
'core/lostpassword'
,
'lostpassword'
,
array
(
'error'
=>
false
,
'requested'
=>
true
));
$sectoken
=
rand
(
1000000
,
9999999
);
$_SESSION
[
'sectoken'
]
=
$sectoken
;
OC_Template
::
printGuestPage
(
'core/lostpassword'
,
'lostpassword'
,
array
(
'error'
=>
false
,
'requested'
=>
true
,
'sectoken'
=>
$sectoken
));
}
else
{
}
else
{
OC_Template
::
printGuestPage
(
'core/lostpassword'
,
'lostpassword'
,
array
(
'error'
=>
true
,
'requested'
=>
false
));
$sectoken
=
rand
(
1000000
,
9999999
);
$_SESSION
[
'sectoken'
]
=
$sectoken
;
OC_Template
::
printGuestPage
(
'core/lostpassword'
,
'lostpassword'
,
array
(
'error'
=>
true
,
'requested'
=>
false
,
'sectoken'
=>
$sectoken
));
}
}
}
else
{
}
else
{
OC_Template
::
printGuestPage
(
'core/lostpassword'
,
'lostpassword'
,
array
(
'error'
=>
false
,
'requested'
=>
false
));
$sectoken
=
rand
(
1000000
,
9999999
);
$_SESSION
[
'sectoken'
]
=
$sectoken
;
OC_Template
::
printGuestPage
(
'core/lostpassword'
,
'lostpassword'
,
array
(
'error'
=>
false
,
'requested'
=>
false
,
'sectoken'
=>
$sectoken
));
}
}
This diff is collapsed.
Click to expand it.
core/lostpassword/templates/lostpassword.php
+
1
−
0
View file @
6bdefef3
...
@@ -10,6 +10,7 @@
...
@@ -10,6 +10,7 @@
<p
class=
"infield"
>
<p
class=
"infield"
>
<label
for=
"user"
class=
"infield"
>
<?php
echo
$l
->
t
(
'Username'
);
?>
</label>
<label
for=
"user"
class=
"infield"
>
<?php
echo
$l
->
t
(
'Username'
);
?>
</label>
<input
type=
"text"
name=
"user"
id=
"user"
value=
""
autocomplete=
"off"
required
autofocus
/>
<input
type=
"text"
name=
"user"
id=
"user"
value=
""
autocomplete=
"off"
required
autofocus
/>
<input
type=
"hidden"
name=
"sectoken"
id=
"sectoken"
value=
"
<?php
echo
(
$_
[
'sectoken'
]);
?>
"
/>
</p>
</p>
<input
type=
"submit"
id=
"submit"
value=
"
<?php
echo
$l
->
t
(
'Request reset'
);
?>
"
/>
<input
type=
"submit"
id=
"submit"
value=
"
<?php
echo
$l
->
t
(
'Request reset'
);
?>
"
/>
<?php
endif
;
?>
<?php
endif
;
?>
...
...
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