summaryrefslogtreecommitdiff
path: root/public/app/extends/App_manager.php
blob: 764153011f2e09ad507d14ee9e0509d7cf21b905 (plain)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php 
namespace app\extends;

use UserManager;
use Registry;


/** ClassUserManager
 * 
 * extends (anom's) UserManager
 * 
 * this way it specializes the UserManagement
 * according to this app's special rules
 * 
 */
class App_manager extends UserManager
{

    private $index_key = 'email';    // identifing user field (username, email, etc )

    protected $user;


    /** constructor
     * --- -- -- - - -
     */
    public function __construct()
    {
        parent::__construct();
    }


    /** register user
     * 
     * register into database;
     * send OTP for account confirmation
     * 
     * @param (void) : user properties passed via REQUEST->POST
     * 
     */
    public function register_user()
    {
        $req = Registry::get('REQUEST');
        $register = Access_model::registerUser($req->POST);

        if ($register['success']) {
            
            //create OTP;
            $otp = $this->create_OPT($register['id']);
            
            // send for account confirmation


        } else {
            print_r($register);
        }

    }


//    /** createUserToken()
//     * == serializes user and stores it into session
//     * so $_SESSION[DEFAULT_PREFIX_KEY] has the serialized representaion of user
//     */
//    public function createUserToken(UserInterface $user): UserTokenInterface
//    {
//        $userToken = new UserToken($user);
//        $_SESSION[UserTokenInterface::DEFAULT_PREFIX_KEY] = $userToken->serialize();
//
//        return $userToken;
//    }

    /** ??
     * 
     */
    public function login_user()
    {
        
    }


    /** forgot password
     * 
     * send an otp
     * (then verify)
     * 
     */
    public function forgot_password()
    {

    }


    /** create OTP
     * 
     * create a random OTP
     * keep it into User's database Table
     * 
     * @param $id (int): user id
     * 
     */
    public function create_OTP($id)
    {
        $otp = rand(100000,999999);
        Access_model::set_OTP($id, $otp);

        return true;
    }


    /** Verify Account
     * 
     * check if posted OTP matched the one sent to the user
     * 
     * @param $identity (array): pair of [index_key => identity_value]
     *      example: [ 'email' => 'geo@roptron.gr' ]
     * 
     */
    public function verify_otp($identity, $otp)
    {

    }


}