Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 01-10-2012, 12:15 PM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 49
BenCrosthwaite is on a distinguished road
Default Login Process - Determining if user has already logged in

Hello Everyone,

I'm building an application, which requires the user to log in. Once the user has logged in, they will not need to log in again if the close and re-open the application.

If the log in is successful I store the password in the keychain, using the code from this blog.

This is where I am stuck. If the user has closed the application and then reopened it, the application will start up again. From this point I need to determine if their login credentials are valid, username and password, if so there is no need to display the login screen.

Using the Keychain code from above, the method to return the password requires the username and service name

Code:
+ (NSString *) getPasswordForUsername: (NSString *) username andServiceName: (NSString *) serviceName error: (NSError **) error
The service name is not an issue but the username is presenting me with a problem.

What is the best way to store the username in order to check if the keychain value exists?

Regards,
-Ben
BenCrosthwaite is offline   Reply With Quote
Old 01-10-2012, 12:36 PM   #2 (permalink)
Registered Member
 
Join Date: May 2010
Posts: 577
Speed is on a distinguished road
Default

Why don't you store the username in the keychain as well? I believe that the keychain works in key-value pairs, which would allow you to store the username under the key "username" and the password under the key "password" (or something similar). This is what I do in my keychain-utilizing application, that has this same functionality.
Speed is offline   Reply With Quote
Old 01-10-2012, 02:58 PM   #3 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 49
BenCrosthwaite is on a distinguished road
Default

Hi Speed,

Thanks for the promt response. I think i may have been confused by the use of language on the SFHFKeychainUtils add method.

The add method is:
Code:
+ (BOOL) storeUsername: (NSString *) username andPassword: (NSString *) password forServiceName: (NSString *) serviceName updateExisting: (BOOL) updateExisting error: (NSError **) error;
I assumed that this meant i was saving both the username and the password the user inputs in the log in form.

However, im starting to think this is the key value system. So storeUsername: (NSString *) username: is the key and andPassword: (NSString *) password is the value.

Is this correct?

Regards,
-Ben
BenCrosthwaite is offline   Reply With Quote
Old 01-10-2012, 03:39 PM   #4 (permalink)
Registered Member
 
Join Date: Aug 2011
Posts: 18
aaronov is on a distinguished road
Default

From memory I store the username in the user defaults, if it is present and a password exists in the keychain then I attempt login with those details - if login fails I then show the login screen.
aaronov is offline   Reply With Quote
Old 01-10-2012, 04:07 PM   #5 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Quote:
Originally Posted by aaronov View Post
From memory I store the username in the user defaults, if it is present and a password exists in the keychain then I attempt login with those details - if login fails I then show the login screen.
User defaults are an extremely insecure way of storing any sensitive data.
baja_yu is offline   Reply With Quote
Old 01-24-2012, 04:52 AM   #6 (permalink)
Survivor
 
Join Date: Jan 2012
Posts: 41
Sunny46 is on a distinguished road
Default

Quote:
Originally Posted by baja_yu View Post
User defaults are an extremely insecure way of storing any sensitive data.
I am having problem using SFHFKeychainUtils.h for ios 5 ,can anyone help me finding the version for ios5?
Sunny46 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 386
10 members and 376 guests
Atatator, buggen, guusleijsten, j.b.rajesh@gmail.com, morterbaher, QuantumDoja, sacha1996, Sami Gh, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 05:36 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0