Skip to content

Commit

Permalink
allow login with email
Browse files Browse the repository at this point in the history
  • Loading branch information
tanutapi committed Mar 21, 2020
1 parent 6538f3e commit e436d99
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions lib/src/meteor_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ class MeteorClient {
/// Log the user in with a password.
///
/// [user]
/// Either a string interpreted as a username or an email; or an object with a single key: email, username or id. Username or email match in a case insensitive manner.
/// Either a string interpreted as a username or an email;
/// or an object with a single key: email, username or id.
/// Username or email match in a case insensitive manner.
///
/// [password] password
///
Expand All @@ -393,9 +395,17 @@ class MeteorClient {
Completer<MeteorClientLoginResult> completer = Completer();
_loggingIn = true;
_loggingInSubject.add(_loggingIn);

var selector;
if (!user.contains('@')) {
selector = {'email': user};
} else {
selector = {'username': user};
}

call('login', [
{
'user': {'username': user},
'user': selector,
'password': {
'digest': sha256.convert(utf8.encode(password)).toString(),
'algorithm': 'sha-256'
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: dart_meteor
description: This library make connection between meteor backend and flutter app easily. Design to work seamlessly with StreamBuilder and FutureBuilder.
version: 1.0.6
version: 1.0.7
homepage: https://github.com/tanutapi/dart_meteor
author: Tanut Apiwong <[email protected]>

Expand Down

0 comments on commit e436d99

Please sign in to comment.