We're going to go through this slowly, but I think you're going to love how quickly we're able to add this functionality with all of the code we've written so far.
1. Open
classes/user.php
.2. Create a
public
function calledlogin
to which we can pass our plain-text$password
as a parameter.public function login($password) { } Create a new bones object and set the database to _users. public function login($password) { $bones = new Bones(); $bones->couch->setDatabase('_users'); }
3. Create a
try...catch
statement for our login code to live in. In thecatch
block, we are going to catch the error code401
. If it is triggered, we want to tell the user that their login was incorrect.public function login($password) { $bones = new Bones(); $bones->couch->setDatabase('_users'); try { } catch(SagCouchException $e) { if($e->getCode() == "401") { $bones->set('error', ' Incorrect login credentials.'); $bones->render...