Have login-checks and CSRF checks

remotes/origin/stable6
kondou 12 years ago
parent 8fd76e39cf
commit 6db96603a0
  1. 20
      core/avatar/controller.php
  2. 2
      core/js/jquery.avatar.js
  3. 2
      settings/js/personal.js

@ -10,12 +10,8 @@ namespace OC\Core\Avatar;
class Controller { class Controller {
public static function getAvatar($args) { public static function getAvatar($args) {
if (!\OC_User::isLoggedIn()) { \OC_JSON::checkLoggedIn();
$l = new \OC_L10n('core'); \OC_JSON::callCheck();
header("HTTP/1.0 403 Forbidden");
\OC_Template::printErrorPage($l->t("Permission denied"));
return;
}
$user = stripslashes($args['user']); $user = stripslashes($args['user']);
$size = (int)$args['size']; $size = (int)$args['size'];
@ -41,6 +37,9 @@ class Controller {
} }
public static function postAvatar($args) { public static function postAvatar($args) {
\OC_JSON::checkLoggedIn();
\OC_JSON::callCheck();
$user = \OC_User::getUser(); $user = \OC_User::getUser();
if (isset($_POST['path'])) { if (isset($_POST['path'])) {
@ -93,6 +92,9 @@ class Controller {
} }
public static function deleteAvatar($args) { public static function deleteAvatar($args) {
\OC_JSON::checkLoggedIn();
\OC_JSON::callCheck();
$user = \OC_User::getUser(); $user = \OC_User::getUser();
try { try {
@ -105,6 +107,9 @@ class Controller {
} }
public static function getTmpAvatar($args) { public static function getTmpAvatar($args) {
\OC_JSON::checkLoggedIn();
\OC_JSON::callCheck();
$tmpavatar = \OC_Cache::get('tmpavatar'); $tmpavatar = \OC_Cache::get('tmpavatar');
if (is_null($tmpavatar)) { if (is_null($tmpavatar)) {
$l = new \OC_L10n('core'); $l = new \OC_L10n('core');
@ -120,6 +125,9 @@ class Controller {
} }
public static function postCroppedAvatar($args) { public static function postCroppedAvatar($args) {
\OC_JSON::checkLoggedIn();
\OC_JSON::callCheck();
$user = \OC_User::getUser(); $user = \OC_User::getUser();
if (isset($_POST['crop'])) { if (isset($_POST['crop'])) {
$crop = $_POST['crop']; $crop = $_POST['crop'];

@ -66,7 +66,7 @@
var $div = this; var $div = this;
OC.Router.registerLoadedCallback(function() { OC.Router.registerLoadedCallback(function() {
var url = OC.Router.generate('core_avatar_get', {user: user, size: size}); var url = OC.Router.generate('core_avatar_get', {user: user, size: size})+'?requesttoken='+oc_requesttoken;
$.get(url, function(result) { $.get(url, function(result) {
if (typeof(result) === 'object') { if (typeof(result) === 'object') {
$div.placeholder(result.user); $div.placeholder(result.user);

@ -58,7 +58,7 @@ function showAvatarCropper() {
$cropper = $('#cropper'); $cropper = $('#cropper');
$cropperImage = $('#cropper img'); $cropperImage = $('#cropper img');
$cropperImage.attr('src', OC.Router.generate('core_avatar_get_tmp')+'#'+Math.floor(Math.random()*1000)); $cropperImage.attr('src', OC.Router.generate('core_avatar_get_tmp')+'?requesttoken='+oc_requesttoken+'#'+Math.floor(Math.random()*1000));
// Looks weird, but on('load', ...) doesn't work in IE8 // Looks weird, but on('load', ...) doesn't work in IE8
$cropperImage.ready(function(){ $cropperImage.ready(function(){

Loading…
Cancel
Save