Validate email on save

This commit is contained in:
Tom Needham 2012-06-04 18:42:25 +00:00
parent b117a1e3ec
commit daa4d2cd84
1 changed files with 4 additions and 5 deletions

View File

@ -8,12 +8,11 @@ OC_JSON::checkLoggedIn();
$l=OC_L10N::get('core');
// Get data
if( isset( $_POST['email'] ) ){
$email=trim($_POST['email']);
if( isset( $_POST['email'] ) && filter_var( $_POST['email'], FILTER_VALIDATE_EMAIL) ){ $email=trim($_POST['email']);
OC_Preferences::setValue(OC_User::getUser(),'settings','email',$email);
OC_JSON::success(array("data" => array( "message" => $l->t("email Changed") )));
OC_JSON::success(array("data" => array( "message" => $l->t("Email saved") )));
}else{
OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") )));
OC_JSON::error(array("data" => array( "message" => $l->t("Invalid email") )));
}
?>