This repository has been archived by the owner on Jun 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 201
/
account_password.php
53 lines (36 loc) · 1.82 KB
/
account_password.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
/*
$Id$
CE Phoenix, E-Commerce made Easy
https://phoenixcart.org
Copyright (c) 2021 Phoenix Cart
Released under the GNU General Public License
*/
require 'includes/application_top.php';
$OSCOM_Hooks->register_pipeline('loginRequired');
// if password is not enabled, then no reason to be on this page
if (!$customer_data->has(['password'])) {
tep_redirect(tep_href_link('index.php'));
}
// needs to be included earlier to set the success message in the messageStack
require language::map_to_translation('account_password.php');
$page_fields = [ 'password', 'password_confirmation' ];
$message_stack_area = 'account_password';
if (tep_validate_form_action_is('process')) {
$password_current = Text::input($_POST['password_current']);
$customer_details = $customer_data->process($page_fields);
if (tep_form_processing_is_valid()) {
$check_customer_query = tep_db_query($customer_data->build_read(['password'], 'customers', ['id' => (int)$_SESSION['customer_id']]));
$check_customer = $check_customer_query->fetch_assoc();
if (tep_validate_password($password_current, $customer_data->get('password', $check_customer))) {
$customer_data->update(['password' => $customer_data->get('password', $customer_details)], ['id' => (int)$_SESSION['customer_id']]);
tep_db_query("UPDATE customers_info SET customers_info_date_account_last_modified = NOW() WHERE customers_info_id = " . (int)$_SESSION['customer_id']);
$messageStack->add_session('account', SUCCESS_PASSWORD_UPDATED, 'success');
tep_redirect(tep_href_link('account.php'));
} else {
$messageStack->add($message_stack_area, ERROR_CURRENT_PASSWORD_NOT_MATCHING);
}
}
}
require $oscTemplate->map_to_template(__FILE__, 'page');
require 'includes/application_bottom.php';