Session between REST calls with node.js for mobile












0















I have to do registration for a mobile app with node.js (express.js) backend. The registration process involves sevaral steps:
1. provide email
2. verify email
3. provide personal details
4. upload photo



For each of these steps there should be a separate call to the server API ( possibly through REST ).
How to keep the session so that the server knows that the consecutive calls come from the same client ? This is a mobile app so cookie based session won't work I think. Could you guide me somehow ? Is using a JWT token the right way to go ?










share|improve this question



























    0















    I have to do registration for a mobile app with node.js (express.js) backend. The registration process involves sevaral steps:
    1. provide email
    2. verify email
    3. provide personal details
    4. upload photo



    For each of these steps there should be a separate call to the server API ( possibly through REST ).
    How to keep the session so that the server knows that the consecutive calls come from the same client ? This is a mobile app so cookie based session won't work I think. Could you guide me somehow ? Is using a JWT token the right way to go ?










    share|improve this question

























      0












      0








      0








      I have to do registration for a mobile app with node.js (express.js) backend. The registration process involves sevaral steps:
      1. provide email
      2. verify email
      3. provide personal details
      4. upload photo



      For each of these steps there should be a separate call to the server API ( possibly through REST ).
      How to keep the session so that the server knows that the consecutive calls come from the same client ? This is a mobile app so cookie based session won't work I think. Could you guide me somehow ? Is using a JWT token the right way to go ?










      share|improve this question














      I have to do registration for a mobile app with node.js (express.js) backend. The registration process involves sevaral steps:
      1. provide email
      2. verify email
      3. provide personal details
      4. upload photo



      For each of these steps there should be a separate call to the server API ( possibly through REST ).
      How to keep the session so that the server knows that the consecutive calls come from the same client ? This is a mobile app so cookie based session won't work I think. Could you guide me somehow ? Is using a JWT token the right way to go ?







      node.js rest session mobile






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 26 '18 at 10:34









      frikofriko

      1761415




      1761415
























          2 Answers
          2






          active

          oldest

          votes


















          0














          I'm not an expert but...



          So here you need to firstly answear a question:
          How much time does user have to create such account? For example, if you won't store information that user had started to create account and server restarted ( for whatever reason. eg error ), you will lose this info. So it would be worth to store this in some db.



          You can use redis, mongodb, some sql db or just system files (not recommended ) it's up to you.



          Assuming you want to persist such info, you can create REST endpoints.
          So for example, you can have entry in MongoDB (which basically stores JSON structures).



          NewAccount { id: <unique_id> , email, info, images }


          So each endpoint you create will set info in this MongoDB entry.



          Example:



          1) POST /user/create -> this would create entry in MongodDB
          2) PUT /user/create { body: { field: 'email', value: 'p@pp.pl' }}
          3) POST /user/create/finish



          We have one more question -> how to identify user? You can try to identify it by IP address. If it's mobile app, you have different ways to store info (eg user token) eg:
          https://developer.android.com/guide/topics/data/data-storage






          share|improve this answer































            0














            As per your step given :




            sevaral steps: 1. provide email 2. verify email 3. provide personal details 4. upload photo




            1.Register by email and password




            Suggestion: You need to ask for email and password.




            i) When a user enters the email and password check user exists with email if not then send a verified email and redirect to login.



            2. Once User verified. Now user tries to log in.



            i) When a user tries to login check email and password is correct or not.



            ii) If correct then generate JWT Token on the backend and send back to APP.



            ii) Now using JWT Token you can manage the user session on the app.






            share|improve this answer
























              Your Answer






              StackExchange.ifUsing("editor", function () {
              StackExchange.using("externalEditor", function () {
              StackExchange.using("snippets", function () {
              StackExchange.snippets.init();
              });
              });
              }, "code-snippets");

              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "1"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: true,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: 10,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479242%2fsession-between-rest-calls-with-node-js-for-mobile%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              0














              I'm not an expert but...



              So here you need to firstly answear a question:
              How much time does user have to create such account? For example, if you won't store information that user had started to create account and server restarted ( for whatever reason. eg error ), you will lose this info. So it would be worth to store this in some db.



              You can use redis, mongodb, some sql db or just system files (not recommended ) it's up to you.



              Assuming you want to persist such info, you can create REST endpoints.
              So for example, you can have entry in MongoDB (which basically stores JSON structures).



              NewAccount { id: <unique_id> , email, info, images }


              So each endpoint you create will set info in this MongoDB entry.



              Example:



              1) POST /user/create -> this would create entry in MongodDB
              2) PUT /user/create { body: { field: 'email', value: 'p@pp.pl' }}
              3) POST /user/create/finish



              We have one more question -> how to identify user? You can try to identify it by IP address. If it's mobile app, you have different ways to store info (eg user token) eg:
              https://developer.android.com/guide/topics/data/data-storage






              share|improve this answer




























                0














                I'm not an expert but...



                So here you need to firstly answear a question:
                How much time does user have to create such account? For example, if you won't store information that user had started to create account and server restarted ( for whatever reason. eg error ), you will lose this info. So it would be worth to store this in some db.



                You can use redis, mongodb, some sql db or just system files (not recommended ) it's up to you.



                Assuming you want to persist such info, you can create REST endpoints.
                So for example, you can have entry in MongoDB (which basically stores JSON structures).



                NewAccount { id: <unique_id> , email, info, images }


                So each endpoint you create will set info in this MongoDB entry.



                Example:



                1) POST /user/create -> this would create entry in MongodDB
                2) PUT /user/create { body: { field: 'email', value: 'p@pp.pl' }}
                3) POST /user/create/finish



                We have one more question -> how to identify user? You can try to identify it by IP address. If it's mobile app, you have different ways to store info (eg user token) eg:
                https://developer.android.com/guide/topics/data/data-storage






                share|improve this answer


























                  0












                  0








                  0







                  I'm not an expert but...



                  So here you need to firstly answear a question:
                  How much time does user have to create such account? For example, if you won't store information that user had started to create account and server restarted ( for whatever reason. eg error ), you will lose this info. So it would be worth to store this in some db.



                  You can use redis, mongodb, some sql db or just system files (not recommended ) it's up to you.



                  Assuming you want to persist such info, you can create REST endpoints.
                  So for example, you can have entry in MongoDB (which basically stores JSON structures).



                  NewAccount { id: <unique_id> , email, info, images }


                  So each endpoint you create will set info in this MongoDB entry.



                  Example:



                  1) POST /user/create -> this would create entry in MongodDB
                  2) PUT /user/create { body: { field: 'email', value: 'p@pp.pl' }}
                  3) POST /user/create/finish



                  We have one more question -> how to identify user? You can try to identify it by IP address. If it's mobile app, you have different ways to store info (eg user token) eg:
                  https://developer.android.com/guide/topics/data/data-storage






                  share|improve this answer













                  I'm not an expert but...



                  So here you need to firstly answear a question:
                  How much time does user have to create such account? For example, if you won't store information that user had started to create account and server restarted ( for whatever reason. eg error ), you will lose this info. So it would be worth to store this in some db.



                  You can use redis, mongodb, some sql db or just system files (not recommended ) it's up to you.



                  Assuming you want to persist such info, you can create REST endpoints.
                  So for example, you can have entry in MongoDB (which basically stores JSON structures).



                  NewAccount { id: <unique_id> , email, info, images }


                  So each endpoint you create will set info in this MongoDB entry.



                  Example:



                  1) POST /user/create -> this would create entry in MongodDB
                  2) PUT /user/create { body: { field: 'email', value: 'p@pp.pl' }}
                  3) POST /user/create/finish



                  We have one more question -> how to identify user? You can try to identify it by IP address. If it's mobile app, you have different ways to store info (eg user token) eg:
                  https://developer.android.com/guide/topics/data/data-storage







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 26 '18 at 10:44









                  Daniel SłabyDaniel Słaby

                  80111




                  80111

























                      0














                      As per your step given :




                      sevaral steps: 1. provide email 2. verify email 3. provide personal details 4. upload photo




                      1.Register by email and password




                      Suggestion: You need to ask for email and password.




                      i) When a user enters the email and password check user exists with email if not then send a verified email and redirect to login.



                      2. Once User verified. Now user tries to log in.



                      i) When a user tries to login check email and password is correct or not.



                      ii) If correct then generate JWT Token on the backend and send back to APP.



                      ii) Now using JWT Token you can manage the user session on the app.






                      share|improve this answer




























                        0














                        As per your step given :




                        sevaral steps: 1. provide email 2. verify email 3. provide personal details 4. upload photo




                        1.Register by email and password




                        Suggestion: You need to ask for email and password.




                        i) When a user enters the email and password check user exists with email if not then send a verified email and redirect to login.



                        2. Once User verified. Now user tries to log in.



                        i) When a user tries to login check email and password is correct or not.



                        ii) If correct then generate JWT Token on the backend and send back to APP.



                        ii) Now using JWT Token you can manage the user session on the app.






                        share|improve this answer


























                          0












                          0








                          0







                          As per your step given :




                          sevaral steps: 1. provide email 2. verify email 3. provide personal details 4. upload photo




                          1.Register by email and password




                          Suggestion: You need to ask for email and password.




                          i) When a user enters the email and password check user exists with email if not then send a verified email and redirect to login.



                          2. Once User verified. Now user tries to log in.



                          i) When a user tries to login check email and password is correct or not.



                          ii) If correct then generate JWT Token on the backend and send back to APP.



                          ii) Now using JWT Token you can manage the user session on the app.






                          share|improve this answer













                          As per your step given :




                          sevaral steps: 1. provide email 2. verify email 3. provide personal details 4. upload photo




                          1.Register by email and password




                          Suggestion: You need to ask for email and password.




                          i) When a user enters the email and password check user exists with email if not then send a verified email and redirect to login.



                          2. Once User verified. Now user tries to log in.



                          i) When a user tries to login check email and password is correct or not.



                          ii) If correct then generate JWT Token on the backend and send back to APP.



                          ii) Now using JWT Token you can manage the user session on the app.







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Nov 26 '18 at 12:04









                          IftekharDaniIftekharDani

                          2,1841713




                          2,1841713






























                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Stack Overflow!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53479242%2fsession-between-rest-calls-with-node-js-for-mobile%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Create new schema in PostgreSQL using DBeaver

                              Deepest pit of an array with Javascript: test on Codility

                              Costa Masnaga