Skip to content

Commit

Permalink
Do not permit login with obviously invalid email
Browse files Browse the repository at this point in the history
It’s next to impossible to ensure an email is valid, so simply check for the general form of an email address.
  • Loading branch information
winny- committed Apr 16, 2014
1 parent 738719e commit 32a6acb
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/Controllers/AuthController.m
Expand Up @@ -4,6 +4,8 @@
#import "StationsController.h"
#import "Notifications.h"

#define ROUGH_EMAIL_REGEX @"[^\\s@]+@[^\\s@]+\\.[^\\s@]+"

@implementation AuthController

- (id) init {
Expand Down Expand Up @@ -88,9 +90,11 @@ - (IBAction) logout: (id) sender {
}

- (void)controlTextDidChange:(NSNotification *)obj {
NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", ROUGH_EMAIL_REGEX];

[login setEnabled:
[spinner isHidden] &&
![[username stringValue] isEqualToString:@""] &&
[emailTest evaluateWithObject:[username stringValue]] &&
![[password stringValue] isEqualToString:@""]];
}

Expand Down

0 comments on commit 32a6acb

Please sign in to comment.