YAFLogo

jspiker77
  • jspiker77
  • 50.6% (Neutral)
  • YAF Forumling Topic Starter
14 years ago
All,

I am currently trying to figure out the process of creating user accounts outside of my site. I'm looking to create a web service that interacts with my software to allow users to register their software and then at the same time create an account on my support forum.

My question is this, can you please point me in the right direction on what information is needed in the database. The one thing that is truly confusing me right now is how the password is stored and retrieved and what tables need to be populated, I have spent the last few hours playing with the database and tracing the code but I feel I am missing something.

Also feel free to give me some feedback on my implementation of YAF http://forum.invoiceexpert.com 

TIA,

John

Sponsor
bz
  • bz
  • 50.6% (Neutral)
  • YAF Forumling
14 years ago
Hello

It is incredible to tell that I have installed YAF for exactly same purpose in mind. To go even further, I want to enable my users to write to forum and get replies right inside my software. A sort of built-in technical support and discussion board.

Therefore, I m writing right now full fledged web service. Though I m bit embarraced with the emerging inner support for web service in curent SVN. Look at YafWebService.cs. Though it is very limited so far.

So i m in wonder, if we may unite efforts to write something ourselves or just await for the authors of this excellent product to finish their development.

Up to your question, it is very easily resolved through the present DB layer. This is my very ugly first prototype i wrote today:

---------------------------------------------------------------------

    static public int CreateUser(int blogid, string login, string password, string email, string address)
    {
      if (UserMembershipHelper.UserExists(login, email))
      {
        // "Username or email are already registered."
        return 0;
      }

      string hashinput = DateTime.Now.ToString() + email + Security.CreatePassword(20);
      string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(hashinput, "md5");

      MembershipCreateStatus status;
      MembershipUser user = Membership.CreateUser(login, password, email, "Address", address, true, out status);

      if (status != MembershipCreateStatus.Success)
      {
        // error of some kind
        // "Membership Error Creating User: " + status.ToString()
        return 0;
      }

      // setup inital roles (if any) for this user
      RoleMembershipHelper.SetupUserRoles(blogid, login);

      // create the user in the YAF DB as well as sync roles...
      int? userID = RoleMembershipHelper.CreateForumUser(user, blogid);

      // create profile
      YafUserProfile userProfile = null; //PageContext.GetProfile(newUsername);

      // setup their inital profile information
      userProfile.Location = address;
      userProfile.Save();

      // save the time zone...
      //YAF.Classes.Data.DB.user_save(UserMembershipHelper.GetUserIDFromProviderUserKey(user.ProviderUserKey), PageContext.PageBoardID, null, null, Convert.ToInt32(TimeZones.SelectedValue), null, null, null, null, null);

      // success
      return userID;
    }