Git Product home page Git Product logo

Comments (4)

Sunedge avatar Sunedge commented on May 30, 2024

Hello,
putting data in session impossible. I checked it's not big data.
Not giving any error.
Could you help me, please?
session.put('user-data', authResponse.body);
session.put('user-data2', "12345");//for this one not working

from session.

Sunedge avatar Sunedge commented on May 30, 2024

Hello @thetutlage,
Could you help me, please?

from session.

RomainLanz avatar RomainLanz commented on May 30, 2024

Hey @Sunedge! 👋

Could you please be more descriptive of what you are trying to do, what happen and what you expect to happen.

Also, a repository to reproduce your issue would be great.

from session.

Sunedge avatar Sunedge commented on May 30, 2024

Hi @RomainLanz,
I want to put variables into session.
session.put('user-data', authResponse.body);
My data's size is 400 bytes. If user-data size increased it not working and not login.
The Problem is size of session (user-data).
If it's possible increase size session, how can I do it?
Please look at session.put('user-data', authResponse.body); line
Best regards.
//It's my code bellow
'use strict'

const Env = use('Env');

class AuthController {

async login({view,request,response,session,antl}) {
if (request.method() == "POST") {
try {
session.clear();
const username = request.input('username');
const password = request.input('password');

      const loginClient = use('sync-rest-client');
      const authResponse = await
      loginClient.post(Env.get('SAAS_SERVER_URL') + '/auth/login', {
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded'
        },
        payload: "username=" + username + "&password=" + password
      });
      if(authResponse.statusCode==200){
        session.put('user-data', authResponse.body);

        const restClient = use('sync-rest-client');
        const menuDataResp = await
          restClient.post(Env.get('SAAS_SERVER_URL') + '/users/profile/menuDataByUserPermission', {
            headers: {
              'Content-Type': 'application/json',
              'Accept': 'application/json',
              'Authorization': 'Bearer ' + (session.get('user-data') ? session.get('user-data').access_token : '')
            }
          });

        session.put("menu-data",menuDataResp.body);

        response.redirect('/user/auto');
      } else if(authResponse.statusCode==401) {
        return view.render("user.login",{errors:antl.formatMessage('errors.auth_error')})
      } else if(authResponse.statusCode==500) {
        return view.render("user.login",{errors:antl.formatMessage('errors.auth_error_server')})
      }
    } catch (e) {
      return view.render("user.login",{errors:antl.formatMessage('errors.auth_error_server')})
    }
  } else {
    return view.render('user.login', {errors: null})
  }

}

async logout({response,session}) {
session.forget('user-data');
return response.redirect('/login');
}
}

module.exports = AuthController

from session.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.