0
votes

i am working on a chatting based app and using xmpp with my openfire server,I want to add change password functionality in ios.I have searched a lot fopr change password feature(xmpp) and have added a method for change password on xmpp,but failed to do so.I dont know and dont have any ideas also,Please help me,my code for change password is as below:

- (void)goOnline
{

     if (appDelegate.signInORnot == 1)
    {
    self.connectionStatus = OTRProtocolConnectionStatusConnected;

    NSLog(@"Account totaltrip..%@",account.totalTrip);

   [[NSNotificationCenter defaultCenter] postNotificationName:kOTRProtocolLoginSuccess object:self userInfo:[NSDictionary dictionaryWithObject:account.totalTrip forKey:TOTAL_TRIP_KEY]];

    XMPPPresence *presence = [XMPPPresence presence]; // type="available" is implicit

     //Develop By Payal Done

        [[self xmppStream] sendElement:presence];

     [self changePassword];
    }
-(BOOL)changePassword
{

    NSUserDefaults *standardUserDefaults = USERDEFAULT;
    NSString *passNew = nil;
            if (standardUserDefaults)
            passNew = [standardUserDefaults objectForKey:@"Newpwd"];
    NSUserDefaults *standardUserDefaults1 = USERDEFAULT;
    NSString *emailStr = nil;
    if (standardUserDefaults1)
        emailStr = [standardUserDefaults1 objectForKey:@"mailId"];


    NSUserDefaults *standardUserDefaults2 = USERDEFAULT;
    NSString *ID = nil;
    if (standardUserDefaults2)
        ID = [standardUserDefaults2 objectForKey:@"intglCode"];



    ID = [ID stringByAppendingString:@"@openfire.netcluesdemo.com"];
     NSLog(@"===passed JID===%@",ID);
   //NSString *myPassword = passNew;
        if (![_xmppStream isDisconnected]) {
            return YES;
        }

//    NSString *myJID = [USERDEFAULT stringForKey: USERNAME];
//    NSString *myPassword = [USERDEFAULT stringForKey: PASSWORD];

    //CHANGE JIGAR
   NSString *myJID=ID;


    NSString *myPassword=passNew;

    if (myJID == nil || myPassword == nil) {
        return NO;
    }

    [_xmppStream setMyJID:[XMPPJID jidWithString:myJID]];
   account.password = myPassword;
  //  _xmppRegistration = [[XMPPRegistration alloc] init];
//    if([OTRXMPPManager changePassword:myPassword])
//    {
//        return YES;
//    }

  return NO;

}
1
Are you using a web based administration panel. if yes then: most administration of the server is done through a web interface, which runs on the ports 9090 (HTTP) and 9091 (HTTPS) by default. Administrators can connect from anywhere and edit the server and configuration settings.Kumar Utsav
i am really not getting you dear,but i really need your help.jigar
@KumarUtsav- i am still struglling to fix this.can you please help me?jigar

1 Answers

1
votes

Use the following changePassword: function to change the password of user from openfire account:

-(void)changePassword:(NSString *)newPassword {

    NSXMLElement *query = [NSXMLElement elementWithName:@"query" xmlns:@"jabber:iq:register"];

    NSXMLElement *username = [NSXMLElement elementWithName:@"username"
                                               stringValue:[self xmppStream].myJID.user];
    NSXMLElement *password = [NSXMLElement elementWithName:@"password"
                                               stringValue:newPassword];
    [query addChild:username];
    [query addChild:password];

    NSXMLElement *iq = [NSXMLElement elementWithName:@"iq"];
    [iq addAttributeWithName:@"type" stringValue:@"set"];
    [iq addAttributeWithName:@"id" stringValue:[[self xmppStream] generateUUID]];
    [iq addChild:query];
    [[self xmppStream] sendElement:iq];
}

In this function pass the new password in parameter.