results matching ""

    No results matching ""

     4.2.Sign Up Without Password

    ¶ 4.2.1. Prerequisites

    See the Sign Up for more information.

    § 4.2.1.1. Dependent Libraries

    Only need reference two Javascript Libraries in HTML:

    <script src="https://TML.ink/X.tml"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
    

    The first line reference the client function library. This's a dynamic library includes many dynamic components and CDN resources, so don't save to local. The second line is using third-party socket library from CDN.

    § 4.2.1.2. Create a client instance

    tim = TML('wss://x.TML.ink'); //Create a client instance
    

    If you connect multiple servers at the same time, you can create multiple client instances.

    Connect a server, Load authentication module, Provide offline login codes and method, logout codes and method, multi-server login, automatic login, user cache and other functions of authentication. If you don't need these features, you should not execute this line of code.

    ¶ 4.2.2. Sign up a new user without password

    You only need to provide an email address, then you will receive an automatically generated password, and this password will be sent to your email address.

    tim.Signup("contact@TML.ink").then(function(data) {
        alert("Your password is "+data.pwd+".\nAn email has been sent to your email address.");
      })
      .catch(function(err) {
        alert("User already exists.");
      });
    

    ¶ 4.2.3. Complete codes of Sign Up without password

    <HTML>
    <h3>Sign Up Without Password</h3>
    <p>Email:<input type="text" placeholder="Input your email..."></p>
    <p><input type="button" value="Sign Up"></p>
    
    <script src="https://TML.ink/X.tml"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.1.1/socket.io.js"></script>
    <script type="text/JavaScript">
    tim = TML('wss://x.TML.ink');
    
    $input[1].onclick=e=>{
      if($input[0].value.length<3){
        alert("Your email must be longer than three characters.");
      }else{
          tim.Signup($input[0].value).then(function(data) {
            alert("Your password is "+data.pwd+".\nAn email has been sent to your email address.");
          })
          .catch(function(err) {
            alert("User already exists.");
          });
      }
      $input[0].value="";
    }
    </script>
    </HTML>
    

    Run above code in browser: https://Doc.TML.ink/examples/signup2_code.html

    How to run above code in your local computer?View the last article in this chapter.

    Read Like

    Question & Feedback