Hi
Well Im using email address instead of username for a few reasons, first I
dont like having to think up usernames all the time, and usualy the ones I
want are taken. Second I can never rember my username. But mainly because its
easier, everyone knows their email address, and I am working with an exsiting
database so rather than get everyone to come up with a username just email
them a password.
I have got the custom Validate User function now, and think I do it by
adding a line in like:
HttpContext.Current.Session("UserID") = reader.GetValue(1)
This should get the first column in the row for the persons record when they
are being validated. Problem is that is returns a Null.
I could be doing this the wrong way, but at the moment when the user opens
pages to view their orders etc, the datasource SQL is SELECT * FROM orders
WHERE email = User.Identity.Name. So if they change their email after loggin
in
it wont match.
Plus it is awkward putting email address into the orders table, when there
is already the memid field there.
> I'm not sure I fully understand what you're doing and why you're doing it
> ..... but ...
[quoted text clipped - 53 lines]
> > Thanks
> > James
Barrie Wilson - 25 Nov 2007 03:10 GMT
> I could be doing this the wrong way, but at the moment when the user opens
> pages to view their orders etc, the datasource SQL is SELECT * FROM orders
> WHERE email = User.Identity.Name. So if they change their email after
> loggin
> in it wont match.
this is a problem; that's why you want the immutable key identifying the
user as an attribute in the ORDERS row (a column)
then you can retrieve orders with something like this:
SELECT a.id, b.id, b.*
FROM USERS a JOIN ORDERS b ON a.pkID = b.userID
WHERE a.emailAddress = <userEmailAddress>
and it won't matter if they've changed their email address because ORDERS
knows about IDs and doesn't know about email addresses
> Plus it is awkward putting email address into the orders table, when there
> is already the memid field there.
[quoted text clipped - 66 lines]
>> > Thanks
>> > James
James - 25 Nov 2007 11:32 GMT
Hi
Thanks for your help but maybe I wasnt being clear.
The table has a unique key, I just use the email address to log in as its
easier to remember and saves users having to come up with usernames.
I was doing it as Barrie suggested but the problem was that if someone logs
in, user.identity.name is saved as email address. If the first thing they do
is change their email address the user.identity.name is now different to that
on the record. So the query would not work, WHERE email = user.identity.name.
I have now fixed the problem with a little extra code added to the
ValidateUser Function:
mysqlreader.read()
httpcontext.current.session("UserID") = mysqlreader.getint32(0)
This finds the first column in the table (which is the unique key) and adds
its value to the session UserID. Then I don't need to worry about queries
with the email field in as I can just use the session("UserID").
Thanks for your help.
James
> > I could be doing this the wrong way, but at the moment when the user opens
> > pages to view their orders etc, the datasource SQL is SELECT * FROM orders
[quoted text clipped - 84 lines]
> >> > Thanks
> >> > James
kaza - 25 Nov 2007 11:05 GMT
> Hi
>
[quoted text clipped - 81 lines]
>
> - Show quoted text -
is your pirmary key in table user-email adress? if yes why?
usually it is not a good idea to have something like that (primary key
which changes) instead make primary key an interger (auto-increment)
and use column email adress as unique but not as primary key, after
login write intos session variable this integer which will never
changen, this will make your life much much easier.
otherwise update the records as sugessted above
regards