Search code examples
iosmeteormeteor-accountsddp

Meteor iOS DDP package by martin, how to login with username


I am using this DDP package to login from my iOS app:

https://github.com/martijnwalraven/meteor-ios/

But I can only find a method called loginWithEmail.

https://github.com/martijnwalraven/meteor-ios/blob/affe8d13a876a0e6e7c95656339d496cbc54a649/Meteor/METDDPClient%2BAccountsPassword.m

How can I edit this so I can login with the username?


Solution

  • You have to make the method yourself.

    Find METDDPClient+AccountsPassword.h and .m

    In .h you

    - (void)loginWithUsername:(NSString *)username password:(NSString *)password completionHandler:(nullable METLogInCompletionHandler)completionHandler;
    

    And then in .m

    - (void)loginWithUsername:(NSString *)username password:(NSString *)password completionHandler:(METLogInCompletionHandler)completionHandler{
       [self loginWithMethodName:@"login" parameters:@[@{@"user": @{@"username": username}, @"password": @{@"digest": [password SHA256String], @"algorithm": @"sha-256"}}] completionHandler:completionHandler];
    }