Débloquez un tutoriel vidéo après le paiement avec le nodejs Stripe ex: (les tutorials de udemy)

Le problème exposé dans ce sujet a été résolu.

Ça dépend si tu veux la faire dans ton contrôleur ou dans ton template (la vue).

Mais oui ça peut se faire à ce niveau-là pour rediriger l’utilisateur ailleurs s’il n’a pas accès au tutoriel.

viki53

re-bonjour, toujours de vous fatiguer. ok j’ai essayé dans la vue comme suite

<%  if(docs === true) {%>
  <div class="agent-video">
    <div class="gridrow">
      <div class="colnomarg span_1_of_4 menu">
        <div class="logo"><p>Suivre<br>Votre<br>Apprentissage!</p></div>
        <div class="links link1 active"><span>01.</span>&nbsp; test 1 </div>
        <div class="links link2"><span>02.</span>&nbsp; test 2 </div>
        <div class="links link3"><span>03.</span>&nbsp; test 3</div>
        <div class="links link4"><span>04.</span>&nbsp; test 4 </div>
        <div class="links link5"><span>05.</span>&nbsp; test 5 </div>
      </div>
      
      <div class="colnomarg span_3_of_4 content">
        <div class="pages page1 active">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;">
            <div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;">
              <div class="videoFoam=true" style="height:100%;width:100%"> 
                <video width="100%" height="100%" controls>
                  <source src="../public/video/test.mp4" type="video/mp4">
                </video>&nbsp;
              </div>
            </div>
          </div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 1</h2>
              <p>Morbi in nibh elementum, consectetur ligula non, efficitur libero. Cras tincidunt libero non felis venenatis, non mattis neque eleifend. Fusce pharetra at odio eu accumsan. Duis viverra tincidunt ante in vestibulum. Donec eu commodo lectus, quis egestas massa. Duis sit amet purus euismod, sodales felis id, lacinia leo. Praesent pulvinar non dolor in condimentum. Suspendisse ex est, finibus vitae sapien eu, posuere aliquam eros. Aenean quis mauris sit amet metus sagittis vestibulum vel vel sem. Suspendisse urna tortor, tempus sit amet sagittis quis, mattis ac magna.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link2">>&nbsp; Continue</div>
              <div class="btn gray"><&nbsp; Go Back</div>
           
            </div>
          </div>        
        </div>




        <!-- VIDEO 2 -->
        <div class="pages page2">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_avk9twrrbn videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 2</h2>
              <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam sem sapien, porta eu sodales sed, finibus finibus velit. Suspendisse blandit leo eros, eget sollicitudin massa posuere eu. Phasellus viverra id arcu sit amet consectetur. Curabitur consectetur venenatis magna in bibendum. Nam eget leo sit amet nisi commodo congue. Aenean lobortis dignissim lorem, quis suscipit purus maximus eget. Etiam nec euismod ante, id tempus risus. In hac habitasse platea dictumst. Pellentesque dolor diam, pellentesque eget justo non, volutpat iaculis felis. Sed sed sagittis nisl. Vivamus iaculis vestibulum nunc ac pulvinar. Nam in ipsum risus.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link3">>&nbsp; Continue</div>
              <div class="btn link1"><&nbsp; Go Back</div>
              
            </div>
          </div>
        </div>
        <!-- FIN VIDEO2 -->





       
       
       
        <!-- VIDEO3 -->
        <div class="pages page3">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_pukozq6xf0 videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 3</h2>
              <p>Ut tincidunt tortor at tortor rutrum, scelerisque commodo nulla imperdiet. Nunc tincidunt porttitor mi at iaculis. Cras semper tortor et ante fermentum, non sollicitudin ante venenatis. Etiam ornare commodo tortor iaculis congue. Cras hendrerit sollicitudin felis, vitae hendrerit tortor mattis eget. Quisque vel pulvinar massa. Suspendisse aliquam nisi in ipsum laoreet, et sollicitudin nisl congue. Praesent consectetur velit quis pulvinar eleifend. Nam a mollis mauris, eget placerat erat. Nulla facilisi. Pellentesque iaculis convallis elit sit amet finibus. Vivamus convallis, felis nec vulputate scelerisque, eros elit elementum purus, nec eleifend urna diam euismod sapien.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link4">>&nbsp; Continue</div>
              <div class="btn link2"><&nbsp; Go Back</div>
              
            </div>
          </div>
        </div>
        <!-- FIN VIDEO 3 -->

        



         <!-- VIDEO 4 -->
        <div class="pages page4">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_efsrxlup84 videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 4</h2>
              <p>Ut feugiat nibh dui, vel aliquet mauris bibendum in. Aenean vulputate at mauris vulputate mollis. Donec sit amet tempus mi. Morbi iaculis leo nec feugiat interdum. Aenean tempus pretium libero. Morbi dapibus maximus velit eu gravida. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis pulvinar vestibulum erat, sit amet volutpat leo bibendum vel. Nullam eleifend convallis ex eget gravida.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link5">>&nbsp; Continue</div>
              <div class="btn link3"><&nbsp; Go Back</div>
            </div>
          </div>
        </div>




         <!-- VIDEO 5 -->
        <div class="pages page5">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_hs0fhkxyk5 videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 5</h2>
              <p>Maecenas at iaculis dui. Morbi et placerat dui. Pellentesque laoreet tortor nec auctor placerat. Phasellus suscipit finibus ante, ullamcorper pellentesque ligula tincidunt nec. Phasellus quis felis ex. Aliquam elementum, velit eu gravida pharetra, lorem turpis scelerisque lectus, et iaculis sem nunc at nunc. Mauris id odio condimentum, blandit nisi id, blandit tellus.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn gray">>&nbsp; Continue</div>
              <div class="btn link4"><&nbsp; Go Back</div>
    
            </div>
          </div>
        </div>
      </div>
      
    </div>
  </div>


  <script type="text/javascript">
    
$(document).ready(function(){
  //ES6 'let' loop yo
  for (let i = 1; i < 6; i++) {
    $('.link' + i).click( function(){
      $('.links').removeClass('active');
      $('.pages').removeClass('active');
      $('.link'+i).addClass('active');
      $('.page'+i).addClass('active');
    });
  }
  //does this for every .links div on the left side and every 'continue' or 'go back' button with the same classes
});
  </script>
  <%} else {%>

    <h1>not access</h1>
   <%}  %>
   
   //////////  Dans nodejs
   
   const getPass = (req, res) =>{
  Payment.findOne({nomid: req.user}, (err, docs) =>{
      if(err) console.log(err);
      res.render('tutorial', {docs: docs})
  })
}

Et la il me fait Not access alors que cet utilisateur à access parce qu’il a payé

Parce que la condition n’est pas bonne : docs est un document Payment s’il est trouvé, pas true.

viki53

Ah c’est bizarre j’avais en premier essayé ça dans la vue mais ça ne marché pas, il avait toujours accès:

<%  if(docs) {%>
  
  <div class="agent-video">
    <div class="gridrow">
      <div class="colnomarg span_1_of_4 menu">
        <div class="logo"><p>Suivre<br>Votre<br>Apprentissage!</p></div>
        <div class="links link1 active"><span>01.</span>&nbsp; test 1 </div>
        <div class="links link2"><span>02.</span>&nbsp; test 2 </div>
        <div class="links link3"><span>03.</span>&nbsp; test 3</div>
        <div class="links link4"><span>04.</span>&nbsp; test 4 </div>
        <div class="links link5"><span>05.</span>&nbsp; test 5 </div>
      </div>
      
      <div class="colnomarg span_3_of_4 content">
        <div class="pages page1 active">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;">
            <div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;">
              <div class="videoFoam=true" style="height:100%;width:100%"> 
                <video width="100%" height="100%" controls>
                  <source src="../public/video/test.mp4" type="video/mp4">
                </video>&nbsp;
              </div>
            </div>
          </div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 1</h2>
              <p>Morbi in nibh elementum, consectetur ligula non, efficitur libero. Cras tincidunt libero non felis venenatis, non mattis neque eleifend. Fusce pharetra at odio eu accumsan. Duis viverra tincidunt ante in vestibulum. Donec eu commodo lectus, quis egestas massa. Duis sit amet purus euismod, sodales felis id, lacinia leo. Praesent pulvinar non dolor in condimentum. Suspendisse ex est, finibus vitae sapien eu, posuere aliquam eros. Aenean quis mauris sit amet metus sagittis vestibulum vel vel sem. Suspendisse urna tortor, tempus sit amet sagittis quis, mattis ac magna.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link2">>&nbsp; Continue</div>
              <div class="btn gray"><&nbsp; Go Back</div>
           
            </div>
          </div>        
        </div>




        <!-- VIDEO 2 -->
        <div class="pages page2">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_avk9twrrbn videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 2</h2>
              <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Nullam sem sapien, porta eu sodales sed, finibus finibus velit. Suspendisse blandit leo eros, eget sollicitudin massa posuere eu. Phasellus viverra id arcu sit amet consectetur. Curabitur consectetur venenatis magna in bibendum. Nam eget leo sit amet nisi commodo congue. Aenean lobortis dignissim lorem, quis suscipit purus maximus eget. Etiam nec euismod ante, id tempus risus. In hac habitasse platea dictumst. Pellentesque dolor diam, pellentesque eget justo non, volutpat iaculis felis. Sed sed sagittis nisl. Vivamus iaculis vestibulum nunc ac pulvinar. Nam in ipsum risus.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link3">>&nbsp; Continue</div>
              <div class="btn link1"><&nbsp; Go Back</div>
              
            </div>
          </div>
        </div>
        <!-- FIN VIDEO2 -->





       
       
       
        <!-- VIDEO3 -->
        <div class="pages page3">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_pukozq6xf0 videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 3</h2>
              <p>Ut tincidunt tortor at tortor rutrum, scelerisque commodo nulla imperdiet. Nunc tincidunt porttitor mi at iaculis. Cras semper tortor et ante fermentum, non sollicitudin ante venenatis. Etiam ornare commodo tortor iaculis congue. Cras hendrerit sollicitudin felis, vitae hendrerit tortor mattis eget. Quisque vel pulvinar massa. Suspendisse aliquam nisi in ipsum laoreet, et sollicitudin nisl congue. Praesent consectetur velit quis pulvinar eleifend. Nam a mollis mauris, eget placerat erat. Nulla facilisi. Pellentesque iaculis convallis elit sit amet finibus. Vivamus convallis, felis nec vulputate scelerisque, eros elit elementum purus, nec eleifend urna diam euismod sapien.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link4">>&nbsp; Continue</div>
              <div class="btn link2"><&nbsp; Go Back</div>
              
            </div>
          </div>
        </div>
        <!-- FIN VIDEO 3 -->

        



         <!-- VIDEO 4 -->
        <div class="pages page4">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_efsrxlup84 videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 4</h2>
              <p>Ut feugiat nibh dui, vel aliquet mauris bibendum in. Aenean vulputate at mauris vulputate mollis. Donec sit amet tempus mi. Morbi iaculis leo nec feugiat interdum. Aenean tempus pretium libero. Morbi dapibus maximus velit eu gravida. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Duis pulvinar vestibulum erat, sit amet volutpat leo bibendum vel. Nullam eleifend convallis ex eget gravida.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn link5">>&nbsp; Continue</div>
              <div class="btn link3"><&nbsp; Go Back</div>
            </div>
          </div>
        </div>




         <!-- VIDEO 5 -->
        <div class="pages page5">
          <div class="wistia_responsive_padding" style="padding:56.25% 0 0 0;position:relative;"><div class="wistia_responsive_wrapper" style="height:100%;left:0;position:absolute;top:0;width:100%;"><div class="wistia_embed wistia_async_hs0fhkxyk5 videoFoam=true" style="height:100%;width:100%">&nbsp;</div></div></div>
          <div class="gridrow">
            <div class="col span_2_of_3">
              <h2>Lorem Ipsum Page 5</h2>
              <p>Maecenas at iaculis dui. Morbi et placerat dui. Pellentesque laoreet tortor nec auctor placerat. Phasellus suscipit finibus ante, ullamcorper pellentesque ligula tincidunt nec. Phasellus quis felis ex. Aliquam elementum, velit eu gravida pharetra, lorem turpis scelerisque lectus, et iaculis sem nunc at nunc. Mauris id odio condimentum, blandit nisi id, blandit tellus.</p>
            </div>
            <div class="col span_1_of_3">
              <div class="btn gray">>&nbsp; Continue</div>
              <div class="btn link4"><&nbsp; Go Back</div>
    
            </div>
          </div>
        </div>
      </div>
      
    </div>
  </div>


  <script type="text/javascript">
    
$(document).ready(function(){
  //ES6 'let' loop yo
  for (let i = 1; i < 6; i++) {
    $('.link' + i).click( function(){
      $('.links').removeClass('active');
      $('.pages').removeClass('active');
      $('.link'+i).addClass('active');
      $('.page'+i).addClass('active');
    });
  }
  //does this for every .links div on the left side and every 'continue' or 'go back' button with the same classes
});
  </script>
  <%} else {%>

    <h1>not access</h1>
   <%}  %>

Et ça donne quoi comme ça ?

viki53

en effet il donne accès au tutorial à tous les utilisateurs connecté même si on ne paie pas. Je croix le probleme se trouve au niveau de:

const getPass = (req, res) =>{
 
 
}
/*** et se bouton au niveau du navbar ***/


        <button class="btn btn-info my-2 my-sm-0 m-3">
          <a class="nav-link text-white " href="/CORAN/<%= id  %>">
          Access aux Cours
          </a>
      </button>
+0 -0

j’ai décidé de changer un peu la configuration

Si l’utilisateur a payé il va accéder directement à un lien (bouton) mais s’il ne paie pas on va lui proposer le tuto tout ça sur une seule page

<%  if(docs)   {%>
          <button class="btn btn-info my-2 my-sm-0 m-3">
            <a class="nav-link text-white " href="/tutorial">
            Access aux Cours
            </a>
        </button>
       <% } else {%>
        <section class="py-2">
          <div class="row">
          <div class="col-md-6 text-center">
      
            <button id="checkout-button" type="submit" class="btn btn-outline-dark text-white btn-lg">acheter maintenant</button>
              <script type="text/javascript">
                // Create an instance of the Stripe object with your publishable API key
                var stripe = Stripe(secret);
               var checkoutButton = document.getElementById('checkout-button');
          
                if(checkoutButton){
                  checkoutButton.addEventListener('click', function() {
                  // Create a new Checkout Session using the server-side endpoint you
                  // created in step 3.
                  fetch('/charge', {
                    method: 'POST',
                  })
                  .then(function(response) {
                    return response.json();
                  })
                  .then(function(session) {
                    return stripe.redirectToCheckout({ sessionId: session.id });
                  })
                  .then(function(result) {
                    // If `redirectToCheckout` fails due to a browser or network
                    // error, you should display the localized error message to your
                    // customer using `error.message`.
                    if (result.error) {
                      alert(result.error.message);
                    }
                  })
                  .catch(function(error) {
                    console.error('Error:', error);
                  });
                });
  
                }
              
              </script>
          </div>
         
        </div>
      </section>

       <%}  %>
const User = require('../models/users')
const Payment = require('../models/payment')

const getSchool = async (req, res) =>{
    let {name, id, email} = req.user
    res.render('compte', {
        name: name,
        id: id

    })

    Payment.find( (err, docs) =>{
        console.log('test: ', id);
        console.dir(docs);
        if(err) console.log(err);
        res.render('compte', {docs: docs})
    })

}


const postCharge = async (req, res) =>{
    let {email, id, name} = req.user
    const savePayment = new Payment({
         Userid: id,
         name: name,
         email: email,

         
     })

    savePayment.save((err, userPayment) =>{
        if(err) console.log(err);
    })



    const session = await stripe.checkout.sessions.create({
        customer_email:  email,
        payment_method_types: ["card"],
        line_items: [
          {
            price_data: {
              currency: "eur",
              product_data: {
                name: "tutorial",
              },
              unit_amount: 2000,
            },
            quantity: 1,
          },
        ],
        mode: "payment",
        success_url: "https://example.com/success",
        cancel_url: "https://example.com/cancel",
      });
      res.json({ id: session.id });
 
}

const getPass = (req, res) =>{
   res.render('tutorial')


}

*Voilà le resultat**

ReferenceError: D:\Node js\papeGeuye\views\compte.ejs:40
   38|
   39|
>> 40|         <%  if(docs)   {%>
   41|           <button class="btn btn-info my-2 my-sm-0 m-3">
   42|             <a class="nav-link text-white " href="/tutorial">
   43|             Access aux Cours

docs is not defined
   at eval (eval at compile (D:\Node js\papeGeuye\node_modules\ejs\lib\ejs.js:661:12), <anonymous>:21:9)
   at compte (D:\Node js\papeGeuye\node_modules\ejs\lib\ejs.js:691:17)
   at tryHandleCache (D:\Node js\papeGeuye\node_modules\ejs\lib\ejs.js:272:36)
   at View.exports.renderFile [as engine] (D:\Node js\papeGeuye\node_modules\ejs\lib\ejs.js:489:10)
   at View.render (D:\Node js\papeGeuye\node_modules\express\lib\view.js:135:8)
   at tryRender (D:\Node js\papeGeuye\node_modules\express\lib\application.js:640:10)
   at Function.render (D:\Node js\papeGeuye\node_modules\express\lib\application.js:592:3)
   at ServerResponse.render (D:\Node js\papeGeuye\node_modules\express\lib\response.js:1012:7)
   at getSchool (D:\Node js\papeGeuye\controllers\user.js:113:9)
   at Layer.handle [as handle_request] (D:\Node js\papeGeuye\node_modules\express\lib\router\layer.js:95:5)
   at next (D:\Node js\papeGeuye\node_modules\express\lib\router\route.js:137:13)
   at ensureAuthenticated (D:\Node js\papeGeuye\config\auth.js:4:16)
   at Layer.handle [as handle_request] (D:\Node js\papeGeuye\node_modules\express\lib\router\layer.js:95:5)
   at next (D:\Node js\papeGeuye\node_modules\express\lib\router\route.js:137:13)
   at Route.dispatch (D:\Node js\papeGeuye\node_modules\express\lib\router\route.js:112:3)
   at Layer.handle [as handle_request] (D:\Node js\papeGeuye\node_modules\express\lib\router\layer.js:95:5)

events.js:200
     throw er; // Unhandled 'error' event
     ^

TypeError: req.next is not a function
   at done (D:\Node js\papeGeuye\node_modules\express\lib\response.js:1007:25)
   at tryRender (D:\Node js\papeGeuye\node_modules\express\lib\application.js:642:5)
   at Function.render (D:\Node js\papeGeuye\node_modules\express\lib\application.js:592:3)
   at ServerResponse.render (D:\Node js\papeGeuye\node_modules\express\lib\response.js:1012:7)
   at D:\Node js\papeGeuye\controllers\user.js:123:13
   at D:\Node js\papeGeuye\node_modules\mongoose\lib\model.js:4838:16
   at D:\Node js\papeGeuye\node_modules\mongoose\lib\model.js:4838:16
   at D:\Node js\papeGeuye\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16
   at D:\Node js\papeGeuye\node_modules\mongoose\lib\model.js:4861:21
   at D:\Node js\papeGeuye\node_modules\mongoose\lib\query.js:4406:11
   at D:\Node js\papeGeuye\node_modules\kareem\index.js:135:16
   at processTicksAndRejections (internal/process/task_queues.js:76:11)
Emitted 'error' event on Function instance at:
   at D:\Node js\papeGeuye\node_modules\mongoose\lib\model.js:4840:13
   at D:\Node js\papeGeuye\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16
   [... lines matching original stack trace ...]
   at processTicksAndRejections (internal/process/task_queues.js:76:11)
+0 -0

Là il y a un problème avec EJS mais je suis pas assez familier avec ce moteur de template pour t’aider.

Ton console.dir(docs) affiche quoi dans ta console ?

viki53

ça me donne ça

[
  model {
    '$__': InternalCache {
      strictMode: true,
      selected: {},
      shardval: undefined,
      saveError: undefined,
      validationError: undefined,
      adhocPaths: undefined,
      removing: undefined,
      inserting: undefined,
      saving: undefined,
      version: undefined,
      getters: {},
      _id: [ObjectID],
      populate: undefined,
      populated: undefined,
      wasPopulated: false,
      scope: undefined,
      activePaths: [StateMachine],
      pathsToScopes: {},
      cachedRequired: {},
      session: null,
      '$setCalled': Set {},
      ownerDocument: undefined,
      fullPath: undefined,
      emitter: [EventEmitter],
      '$options': [Object]
    },
    isNew: false,
    errors: undefined,
    '$locals': {},
    '$op': null,
    _doc: {
      _id: [ObjectID],
      Userid: '5f5a97395923ee3b3499fd93',
      name: 'Mouhamad PADANE',
      email: 'ahmadanote26@gmail.com',
      __v: 0
    },
    '$init': true
  }
]

Donc tu récupères bien un document, mais ta vue n’a pas l’air de recevoir l’info.

Et effectivement, tu appelles deux fois res.render('compte'). La première fois sans passer de variable docs. Il faudra donc adapter ton code, par exemple en ne faisant qu’un seul render. ;)

viki53

Vous avez raison j’ai corrigé et ça me donne le rendu mais quand j’essaie avec un autre utilisateur qui n’a pas payé bizarement il a accés à la tutorial. Mais franchement je m’excuse de votre temps que vous m’accorder.

Je ne sais pas ce qui se passe mais il y’a quelque chose qui ne va pas ici:

  Payment.find((err, docs) =>{
        console.dir(docs);
        if(err) console.log(err);
        res.render('compte', {docs: docs,  name: name})
    })
  

+0 -0
Connectez-vous pour pouvoir poster un message.
Connexion

Pas encore membre ?

Créez un compte en une minute pour profiter pleinement de toutes les fonctionnalités de Zeste de Savoir. Ici, tout est gratuit et sans publicité.
Créer un compte