اذهب إلى المحتوى

Hadi255

الأعضاء
  • المساهمات

    31
  • تاريخ الانضمام

  • تاريخ آخر زيارة

إنجازات Hadi255

عضو مساهم

عضو مساهم (2/3)

16

السمعة بالموقع

  1. أضفت اليوم تعديلا آخر وهو جعل : session: false كما يلي : :index.js router.get('/auth/google', passport.authenticate('google', { scope: ['email', 'profile'] } )); router.get('/auth/google/callback', passport.authenticate('google', { session: false, failureRedirect: 'signup' }), (req, res) => { res.redirect('/users/profile') }); النتيجة أن الصفحة فتحت في المكان المطلوب بنجاح لكن بدون تسجيل الدخول ، وكأنني لم أفعل شيئاً.
  2. users.js .env Carts.js Order.js Product.js User.js checkout.hbs forgotPassword.hbs index.hbs resetPassword.hbs shoppingcart.hbs allUsers.hbs confirmEmail.hbs profile.hbs signin.hbs signup.hbs header.hbs
  3. هذان الملفان اللذان يخصان المشكلة، إن أردت أرسلت بقية الملفات passport.js index.js
  4. أستخدم في المشروع node.js , passport-google-oauth2 ، و أحاول إضافة إمكانية تسجيل الدخول بواسطة جوجل. بعد ظهور اختيار الحساب و الضغط عليه، يعاد توجيه الصفحة بنجاح كما هو مطلوب لكن الصفحة لا تفتح و لا يحدث تسجيل دخول و يظهر الخطأ التالي: [nodemon] app crashed - waiting for file changes before starting... passport.js: passport.use(new GoogleStrategy({ clientID: process.env.GOOGLE_CLIENT_ID, clientSecret: process.env.GOOGLE_CLIENT_SECRET, callbackURL: "http://localhost:4000/auth/google/callback", passReqToCallback: true }, function (request, accessToken, refreshToken, profile, done) { done(null, profile); } )); :index.js router.get('/auth/google', passport.authenticate('google', { scope: ['email', 'profile'] } )); router.get('/auth/google/callback', passport.authenticate('google', { failureRedirect: 'signup' }), (req, res) => { res.redirect('/') });
  5. ربما هذه الميزة قيد التطوير، أو أنه تم تحديثها و لم أعرف ما هو هذا التحديث. على كل حال تم ضبط زمن الصلاحية و دون مشاكل بدون استخدام هذه الميزة . احتجت لأكواد أكثر لكن الحل بسيط.
  6. لا يوجد أي إجابة أو حتى تفاعل، هل السؤال أو الأكواد غير واضحة أو غير مفهومة ؟! يمكنني تعديلها أو توضيحها إن إن كان ضرورياً .
  7. مرحبا أحاول ضبط زمن انتهاء الصلاحية منذ يومين عبثاُ ، تنتهي الصلاحية دوما بعد دقيقتين تقريبا وكأنها قيمة افتراضية لم أستطع تغييرها. Carsts.js: const mongoose = require('mongoose'); const cartSchema = mongoose.Schema({ _id: { required: true, type: String }, totalquantity: { required: true, type: Number }, totalPrice: { required: true, type: Number }, selectedProduct: { required: true, type: [],// or Array }, createAt: { type: Date, expires: 10, // expires: '10', // index: { expireAfterSeconds: 5 } // index:{expires:'1m'} } }, { timestamps: true }) module.exports = mongoose.model('Carts', cartSchema); التعليقات هي فقط بعض المحاولات الكثيرة التي قمت بها . index.js: router.get('/addTocart/:id/:price/:name', (req, res, next) => { const product_id = req.params.id; const cartId = req.user._id; const newproductPrice = +req.params.price; const newProduct = { _id: req.params.id, price: newproductPrice, name: req.params.name, quantity: 1 }; Carts.findOne({ _id: cartId }) .catch((err) => { console.log("Error! :", err) }) .then((cart) => { if (!cart) { const newCart = new Carts({ _id: cartId, totalquantity: 1, totalPrice: newproductPrice, selectedProduct: [newProduct], createAt: Date.now(), }) newCart.save({}) .catch((err) => { console.log(err) }) .then((result) => { console.log('New user: ', result) }) } if (cart) { var indexOfProduct = -1; for (var i = 0; i < cart.selectedProduct.length; i++) { if (product_id === cart.selectedProduct[i]._id) { indexOfProduct = i; break; } } if (indexOfProduct >= 0) { // console.log(cart.selectedProduct[indexOfProduct]); cart.selectedProduct[indexOfProduct].quantity++; cart.selectedProduct[indexOfProduct].price += newproductPrice; cart.selectedProduct[indexOfProduct].price = Math.round(cart.selectedProduct[indexOfProduct].price * 100) / 100; cart.totalquantity++; cart.totalPrice += newproductPrice; cart.totalPrice = Math.round(cart.totalPrice * 100) / 100; cart.createAt = Date.now(); // cart.createAt = Date.now(); Carts.updateOne({ _id: cartId }, { $set: cart }) .catch((err) => { console.log(err) }) .then((result) => { console.log('update:', result); console.log('cart-update: ', cart); }) } else { cart.totalquantity++; cart.totalPrice += newproductPrice; cart.totalPrice = Math.round(cart.totalPrice * 100) / 100; cart.selectedProduct.push(newProduct); cart.createAt = Date.now(); Carts.updateOne({ _id: cartId }, { $set: cart }) .catch((err) => { console.log(err) }) .then((result) => { console.log('add:', result); console.log('cart-add: ', cart); }) } } }) next(); res.redirect('/'); }); إضافة لذلك أنه يوجد تداخل ، أي عندما أبدل إلى مستخدم آخر ( بتسجيل الخروج والدخول باسم آخر ) يتنتهي مدة صلاحية الثاني و يتم حذف كرته رغم أنه يجب أن لا تنتهي بعد.
  8. تماماً لأن تعريف الموجه كان app.directive لكن سؤالي الآن أين يوجد جوابك لم أجده في مكان ؟ هل استنتجته استنتاجاً أم يوجد شبيه له في مكان ما ؟
  9. ممتاز شكراً لك أي مثل طريقة تعريفه ك directive في <script setup> تقريبا (ما عدا أن المتغير ليس بالضرورة Camel case ) مع أنني حاولت هذه الطريق البارحة لا أعلم لماذا لم تنجح يبدو كان هناك خطأ . نجح الأمر الآن شكر اً لك
  10. لقد درست هذا كله منذ يومين و طبقته بسهولة لكنه لا يحتوي الإجابة على سؤالي
  11. نفس الخطأ لم يتغير شيء لا يوجد أخطاء من هذه النواحي فالكود نفسه يعمل عندما أكتبه في ملف main.js
  12. شكرا لك على الإجابة ، لكنه لم يعمل و ظهر لي خطأ لم أستطع فهمه واختفت الصفحة بسبب الخطأ : runtime-dom.esm-bundler.js:13 Uncaught TypeError: Cannot read properties of null (reading 'parentNode') at remove (runtime-dom.esm-bundler.js:13:26) at performRemove (runtime-core.esm-bundler.js:6257:7) at remove2 (runtime-core.esm-bundler.js:6271:7) at unmount (runtime-core.esm-bundler.js:6226:9) at Object.remove (runtime-core.esm-bundler.js:6592:11) at unmount (runtime-core.esm-bundler.js:6205:20) at unmountChildren (runtime-core.esm-bundler.js:6314:7) at unmount (runtime-core.esm-bundler.js:6215:9) at unmountComponent (runtime-core.esm-bundler.js:6294:7) at unmount (runtime-core.esm-bundler.js:6195:7) remove @ runtime-dom.esm-bundler.js:13 performRemove @ runtime-core.esm-bundler.js:6257 remove2 @ runtime-core.esm-bundler.js:6271 unmount @ runtime-core.esm-bundler.js:6226 remove @ runtime-core.esm-bundler.js:6592 unmount @ runtime-core.esm-bundler.js:6205 unmountChildren @ runtime-core.esm-bundler.js:6314 unmount @ runtime-core.esm-bundler.js:6215 unmountComponent @ runtime-core.esm-bundler.js:6294 unmount @ runtime-core.esm-bundler.js:6195 unmountChildren @ runtime-core.esm-bundler.js:6314 unmount @ runtime-core.esm-bundler.js:6215 unmountChildren @ runtime-core.esm-bundler.js:6314 unmount @ runtime-core.esm-bundler.js:6215 unmountComponent @ runtime-core.esm-bundler.js:6294 unmount @ runtime-core.esm-bundler.js:6195 patch @ runtime-core.esm-bundler.js:4991 render2 @ runtime-core.esm-bundler.js:6332 mount @ runtime-core.esm-bundler.js:3824 app.mount @ runtime-dom.esm-bundler.js:1431 (anonymous) @ main.js?t=1688563145513:50 Show 20 more frames هل يمكنك تجريب ذلك و ينجح معك
  13. يمكننا إنشاء ملف جاسكربت (أضع فيه custom directives) و تصديره، ثم استيراده في ملف main.js بسهولة في vue 2. لكني لم أنجح في ذلك في vue 3 ، حيث أني استطعت أن أصدر الدالات (functions) في ملف directives.js إلى main.js وعملت الأكواد فيها، لكن custom directives لم تعمل ، وكأنها غير موجودة . في ملف directives.js المنشأ : // directives.js import { createApp } from 'vue' import App from './App.vue' const app = createApp(App) // global Custom Directive export default function glob() { app.directive('globalexternal', { mounted: function (el) { el.placeholder = 'Global Custom Directive from external file' } }) console.log('Global Custom Directive from external file') } و في ملف main.js الأساسي : // main.js import glob from './directives' glob(); وفي ملف App.vue مثلاُ : // App.vue <input v-globalexternal style="width: 370px" /> النتيجة أن الأمر console.log('Global Custom Directive from external file') قد تم بنجاح ، لكن <input v-globalexternal style="width: 370px" /> لم يعمل v-globalexternal . هل من لديه تجربة في ذلك ؟
×
×
  • أضف...