User Management Basics

Arya MirΔιαχείριση

9 Ιαν 2012 (πριν από 5 χρόνια και 9 μήνες)

855 εμφανίσεις

Objective Learn to create, update, delete, and login users in ProdigyView. Requirements Install version of ProdigyView with a database connection Estimated Time 10 Minutes

User Management Basics

www.prodigyview.com

Overview

Objective

Learn to create, update, delete, and login users in
ProdigyView
.

Requirements


Install version of
ProdigyView

with a database
connection

Estimated Time

10 Minutes

www.prodigyview.com

Follow Along With Code
Example

1.

Download a copy of the example code at
www.prodigyview.com/source
.

2.
Install the system in an environment you feel
comfortable testing in.

3.
Proceed to examples
/user/
Users.php

Users….what about them

A user…a better term would be end users… are probably the
life source of what ever you are building. Without saying, you
need a way to manage them. For this tutorial we are going to
cover:


Creating Users


Logging In


Updating Users


Searching for Users


Deleting Users

Aspects such as user roles, content multi authors, roles,
access levels,
etc

will come later.

Creating A User

Creating a user is fairly simply. Fields are added to an array
and passed to
PVUsers
::
addUser
()
method. Technically the
only field required is the user’s email but lets define some
other fields.

1. Create the fields

2.Passwords will be MD5 encoded

3. Pass arguments to
addUser

4. If set to false, the password is not
considered hashed and will be hashed

Attempt Login

Now that we have a user and we want them to login with
their email or username. Let’s give it a try.

1. Pass the user’s email

2. Pass the user’s password in

3.Set the cookies on
login

4. Check if the user is logged in

www.prodigyview.com

Force Login

Sometimes we need to forcefully log the user in without
password verification. This can be done through
PVUsers
::
loginUser
()
. Either pass in the user’s name or
the user’s email.

www.prodigyview.com

Retrieving the User Info

We have a user in the database and will at some point
need to retrieve their information. If the user’s email or id
is known, their information can be retrieved through those
values.

1. Retrieve a user’s information using their id

2. Retrieve a user’s information using their email

Searching For users

Let’s say we have multiple user’s with our growing site
and we need to somehow search for them based on
certain criteria. Take a look at the
ProdigyView’s

Standard Search Arguments
and combined with
PVUsers
::
getUserList

we can get our results.

Updating A User

User’s can be finicky. They want to update their info,
change their image, etc. Fine, lets give them what they
want. Updating fields can be accomplished by passing the
users fields in an array to
PVUsers
::
updateUser
().
The
only required field is the user’s id.

1. Retrieve the user’s information, returns an array

2. Update a field in the array

3.Update the user using the array

And Deleting

After all the trouble creating a users account, updating
their information, the free coffee, they decide they want to
delete their account. Let’s comply.

Delete a user using their id

Challenge!

We know how to create, update and login a user. For this
challenge we do not want MD5 hashing of the password
but want to encrypt the password ourselves.

Use
PVSecurity

to create a hashed password and
attempt to login with that password.

The Not So Obvious

1.
When a user is deleted, content they are considered owner of
is also deleted. This include subscriptions, points, content,
options and relationships, categories and multi
-
author.

2.
When updating a user, it is best to retrieve and pass in the
whole user document for that user. The reason is because
fields that are left empty will be reverted to their default value.

3.
When a user is logged in, the data in that user’s row from the
database is stored in session/cookie. The column’s name acts
the key and columns value is the value stored.



Ex: $
user_email
=
PVSession
::
readSeassion
(‘
user_email
’);

API Reference

For a better understanding of the users, visit the
api

by
clicking on the link below.

PVUsers


www.prodigyview.com

More Tutorials

For more tutorials, please visit:

http://
www.prodigyview.com
/tutorials