Projekt

Obecné

Profil

« Předchozí | Další » 

Revize b748cb5f

Přidáno uživatelem Tomáš Pašek před téměř 4 roky(ů)

Feature #8522 Login a bezpečnost webové aplikace
Feature #8523 Tvorba uživatele

Zobrazit rozdíly:

application/model/DB.php
65 65
        }
66 66
    }
67 67

  
68
    function getUser($username) {
69
        $this->stmt = $this->pdo->prepare('SELECT id, username, password, role FROM users WHERE username = :username');
70
        $this->stmt->bindParam(':username', $username);
71
        $this->stmt->execute();
72
        return $this->stmt->fetchAll();
73
    }
74

  
75
    function createUser($userDetails) {
76
        $this->stmt = $this->pdo->prepare('INSERT INTO users (username, password, role) VALUES (:username, :password, :role)');
77
        $password = password_hash($userDetails['username'], PASSWORD_DEFAULT);
78
        $this->stmt->bindParam(':username', $userDetails['username']);
79
        $this->stmt->bindParam(':password',$password);
80
        $this->stmt->bindParam(':role',$userDetails['role']);
81
        $this->stmt->execute();
82
        return $this->stmt->fetchAll();
83
    }
84

  
85
    function updateUserRole($userId, $role) {
86
        $this->stmt = $this->pdo->prepare("UPDATE users SET role = :role WHERE id = :userId");
87
        $this->stmt->bindParam(':role', $role);
88
        $this->stmt->bindParam(':userId',$userId);
89
        $this->stmt->execute();
90
        return $this->stmt->fetchAll();
91
    }
92

  
93
    function deleteUser($userId) {
94
        $this->stmt = $this->pdo->prepare("DELETE from users WHERE id = :userId");
95
        $this->stmt->bindParam(':userId',$userId);
96
        $this->stmt->execute();
97
        return $this->stmt->fetchAll();
98
    }
99

  
100

  
101

  
68 102
function update(){
69 103
    $query = "SELECT id FROM dd_lemma
70 104
              WHERE lemma = :lemma;";

Také k dispozici: Unified diff