PHP Classes

File: uploady/profile/actions/auth.php

Recommend this page to a friend!
  Classes of Faris AL-Otabi   Uploady PHP Upload File to MySQL   uploady/profile/actions/auth.php   Download  
File: uploady/profile/actions/auth.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Uploady PHP Upload File to MySQL
Store file upload details in a MySQL database
Author: By
Last change: fix bugs and missing alert in 2fa
Date: 11 months ago
Size: 988 bytes
 

Contents

Class file image Download
<?php
include_once '../../session.php';

$otpauth = new \RobThree\Auth\TwoFactorAuth("Uploady");

if (
$_SERVER['REQUEST_METHOD'] == 'POST') {
    if (
$auth->checkToken($_POST['csrf'], $_SESSION['csrf']) == false) {
       
$msg_code = "csrf";
    } else {
        if (isset(
$_POST['enable'])) {
            if (
$otpauth->verifyCode($_POST['otp_secret'], $_POST['otp_code'])) {
               
$user->update($_POST['id'], [
                   
'otp_status' => true,
                   
'otp_secret' => $_POST['otp_secret'],
                ]);
               
$msg_code = "two_factor_enabled";
            } else {
               
$msg_code = "err";
            }
        }

        if (isset(
$_POST['disable'])) {
           
$user->update($_POST['id'], [
               
'otp_status' => false,
               
'otp_secret' => ''
           
]);
           
$msg_code = "two_factor_disabled";
        }
    }

   
$utils->redirect($utils->siteUrl("/profile/auth.php?msg={$msg_code}"));
}