Giter Site home page Giter Site logo

modules's Introduction

modules's People

Contributors

acardinale avatar asessa avatar bilikaz avatar buzzeins avatar creeplays avatar dacrhu avatar deadman2000 avatar digi59404 avatar evmek avatar flashvnn avatar flienteen avatar gera-g-guiles avatar gnetsys avatar harry-stot avatar helferino avatar jannaahs avatar kipsoft avatar marcelsieber avatar molda avatar patchwerkqwer avatar petersirka avatar tomee03 avatar varunbatrait avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modules's Issues

angular header creation

Hallo Peter,

I was using angular.js with your module and I was wondering why I had allways "undefined" in the header of the outputfile. I think there is a little mistake in this line:

self.repository['$head'] += angularBeg + angularEnd;

If I am not using ngStyle the variable self.repository['$head'] is undefined and it return "undefined" + angularBeg + angularEnd.
Replacing the line with

self.repository['$head'] = (self.repository['$head'] || '') +  angularBeg + angularEnd;

solved the problem.

Thanks for all your work.

get other value in auth

in definition there is authorization

auth.onAuthorization = function(id, callback) {

    // this is cached
    // read user information from database
    // into callback insert the user object (this object is saved to session/cache)
    // this is an example
    callback({id:id});

    // if user not exist then
    // callback(null);
};

how to get value beside id that saved to cookies

Webcounter helpers not working

Hi,

I created empty total.js project and try to use helper webcounter methods to show counter value in homepage.html like this:

@{meta('title', 'description', 'keywords')}

@{visitors()}

<div>Hello world!</div>

Total.js is returning error:

default ---> SyntaxError: Unexpected token ) ([object Object]) SyntaxError: Unexpected token )

When I change @{visitors()} to @{visitors('')} then it is working.
I do not know whether this is the fault of wrong implementation or documentation.

Best regards.

How do definitions work?

I really do not understand definitions. Why and how should I use them? Do you have any good example?

flash is not defined in conditionals?

hello,

i need help in this line of view

@{if flash('error') == null}
    <div class="alert alert-dismissible alert-danger">
        <button type="button" class="close" data-dismiss="alert">x</button>
        <strong>@{flash('error')}</strong>
    </div>
@{fi}

this is the controller

var passport = require('passport');

exports.install = function() {
  F.route('/auth', local_get, ['#session', '#flash']);
    F.route('/auth', local_login_post, ['post', '#session', '#passport.js', '#flash']);
  // or
  // F.route('/');
};

function local_get() {
    var self = this;
    self.view('index');
}

function local_login_post() {
    var self = this;
    passport.authenticate('local-login', {
        successRedirect: '/',
        failureRedirect: '/auth',
        failureFlash: true
    })(self.req, self.res);
}

message error:
500: Internal Server Error :: Error: View: index - ReferenceError: flash is not defined
at Object.Controller.view (E:\GitHub\total-faq\node_modules\total.js\index.js:12420:13)
at Object.local_get (E:\GitHub\total-faq\controllers\auth.js:16:7)
at Subscribe.doExecute (E:\GitHub\total-faq\node_modules\total.js\index.js:9089:23)
at E:\GitHub\total-faq\node_modules\total.js\index.js:9022:8
at Array._async_middleware (E:\GitHub\total-faq\node_modules\total.js\utils.js:4076:4)
at Immediate.res.$middleware as _onImmediate
at processImmediate as _immediateCallback

Error view file not found

I got the following error :

Error: ENOENT, no such file or directory '/public/themes/frontend/default/views/index.html'

It only works if using full path :
/home/cevarief/node/cms/public/themes/frontend/default/views/index.html

auth whether already logged

Hi,

I am referring the below page and I use it.
https://github.com/totaljs/modules/blob/master/Security/auth/example/controllers/default.js

When I click the json_logoff function second time, then the page response is "401: Unauthorized". In the below code, I can I check whether the user already logoff, so I can re-route to some other page.

function json_logoff() {
    var self = this;
    var auth = MODULE('auth');
    var user = self.user;
    auth.logoff(self, user.id);
    self.redirect('/');
}

Stylus @require and @import dont work

While i trying to use (For example) @import "./public/css/common.styl",
i getting this error in console:

Error: stylus:1:9
   1| @import "common.styl"
--------------^
   2| 
   3| .errorName
   4|     position absolute

failed to locate @import file common.styl

    ...
    at Renderer.render (/home/ubuntu/workspace/NGSpaceNG/node_modules/stylus/lib/renderer.js:86:26)
    at /home/ubuntu/workspace/NGSpaceNG/modules/stylus.js:55:69
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:415:3)

auth.js

Readme file example wrong in auth module.

auth.onAuthorization changed v2, auth.onAuthorize.

Peter my idea, more attention backward compatibility for security modules.

Accessing Session in Websocket

Hi Peter,
Is it possible to access the session in websocket connections?
Currently I set a session variable username for each user after login. The client also connects to total.js using websocket to get updates & notifications. I need to get the username in websocket connections to route the notifications.
I access the session in normal total.js contollers via this.session; However It seems this.session is null inside the websocket controller.
My code in controllers/default.js:

exports.install = function(framework) {
    framework.route('/*', view_app);
    // other routes
    framework.websocket('/', socket_homepage, ['json']);
};

function view_app() {
    var self = this;
    // self.session is OK here
}

function socket_homepage() {
    var self = this;
    // self.session is undefine!
}

Question: does websocket requests share the same session cookies with normal http requests? If yes,
is there any way to resolve the session variables based on the cookie sent by the browser?
Thanks in advance,

modules

Hi,

In the definitions/modules.js, I see the below code
INSTALL('module','http://modules.totaljs.com/session/v1.00/session.js');

I have downloaded the session.js and saved under
modules/session.js, ie., I want to load the session from my own hosting path. When I start the totaljs application using debug.js, I see the below error,

======= 2015-03-25 20:07:29: framework.install('module', 'undefined') ---> Refer
enceError: session is not defined ReferenceError: session is not defined

Please advise how to fix this.

Jade/PUG - Global variables

Is it possible to use the global variables in Jade/Pug? (We have rewritten the Jade version to Pug)

exports.install = function(){
    F.global.some_var = "some value";
    F.route("/dashboard", dashboard,    ['authorize']);
});

function some_view(){
    model = {'title' : 'Title'};
    self.view('someview', model);
}

Jade/Pug:

h1= title
div.somediv= global.some_var

I think there is something wrong with in-memory session module

I've just put the module and definition on my project, without really using it, and it is throwing this:

homepage_prod homepage TypeError: Cannot call method 'split' of undefined TypeError: Cannot call method 'split' of undefined
homepage_prod homepage at EventEmitter.eval (eval at (/home/ubuntu/homepage/node_modules/partial.js/index.js:22:10651), :4:60)
homepage_prod homepage at EventEmitter.emit (events.js:98:17)
homepage_prod homepage at Subscribe._execute (/home/ubuntu/homepage/node_modules/partial.js/index.js:24:11699)
homepage_prod homepage at EventEmitter.Async.refresh (/home/ubuntu/homepage/node_modules/partial.js/utils.js:23:423)
homepage_prod homepage at AsyncTask.complete (/home/ubuntu/homepage/node_modules/partial.js/utils.js:22:29597)
homepage_prod homepage at EventEmitter.Session._create (/home/ubuntu/homepage/modules/session.js:75:5)
homepage_prod homepage at EventEmitter.Session._read (/home/ubuntu/homepage/modules/session.js:38:14)
homepage_prod homepage at Object. (/home/ubuntu/homepage/modules/session.js:95:32)
homepage_prod homepage at AsyncTask.run (/home/ubuntu/homepage/node_modules/partial.js/utils.js:22:28705)
homepage_prod homepage at EventEmitter.Async.refresh (/home/ubuntu/homepage/node_modules/partial.js/utils.js:23:197)
homepage_prod homepage at EventEmitter.Async.run (/home/ubuntu/homepage/node_modules/partial.js/utils.js:22:31244)
homepage_prod homepage at Subscribe.execute (/home/ubuntu/homepage/node_modules/partial.js/index.js:24:11034)
homepage_prod homepage at Subscribe.prepare (/home/ubuntu/homepage/node_modules/partial.js/index.js:24:11523)
homepage_prod homepage at Subscribe._end (/home/ubuntu/homepage/node_modules/partial.js/index.js:24:13596)
homepage_prod homepage at IncomingMessage.EventEmitter.emit (events.js:92:17)
homepage_prod homepage at _stream_readable.js:920:16
homepage_prod homepage at process._tickCallback (node.js:415:13)

Using `@` flag for roles...

I'm going to update the auth module readme.md to take account for roles now being done via the @ flags rather than ! flags. However, I just wanted to check - should the roles of a user be defined in the user object or somewhere else?

My guess is that it works like this:

F.onAuthorize = function( id, callback, flags ) {
   // get user associated with id

  var user = { id: result.id, name: result.name, roles: result.roles }
  callback( true, user );
}

Where roles would be a string array, eg. ['admin','moderator']

When routes require a role, use flags, eg:

F.route( '/some/path/', handlerFn, ['@admin'] );

Then the framework will handle the rest?

What if a route has multiple roles? eg. ['@admin','@moderator'] - if the user only has one role admin, will they be allowed to use a route that lists multiple roles, or would used need to have all those roles to use that route?

mail using sendgrid

Hi,

I am hosting my application using Google Compute Engine, and it allow me to send email via SendGrid. Please refer the page at https://cloud.google.com/compute/docs/tutorials/sending-mail#nodejssendgrid

I like to use total.js own mail option which is working well for me now using google smtp.gmail.com. Could you please advise how to configure total.js/mail to work with SendGrid. SendGrid offer it own package at https://sendgrid.com/docs/Integrate/Code_Examples/nodejs.html.

But, still I prefer to use total.js/mail. Please advise.

How to control access in authorization

Hi.
How can I prevent the common user from visiting some pages like admin panel?
I did that with controller.cancel() and controller.throw403() in framework event "controller", but it always throw a framework error to console when a request without permission is passing.

Thx.

dot example error

I tested the dot example and got this error

TypeError: Cannot read property 'contentType' of undefined TypeError: Cannot read property 'contentType' of undefined
at Object.Controller.view (eval at (/Volumes/Data/Cloud/Project/github/partial.js-modules/dot/example/node_modules/partial.js/index.js:22:15139), :1:1204)
at Object.view_homepage (/Volumes/Data/Cloud/Project/github/partial.js-modules/dot/example/controllers/default.js:7:7)
at Subscribe._execute (/Volumes/Data/Cloud/Project/github/partial.js-modules/dot/example/node_modules/partial.js/index.js:24:18952)
at Subscribe.execute (/Volumes/Data/Cloud/Project/github/partial.js-modules/dot/example/node_modules/partial.js/index.js:24:17239)
at Subscribe.prepare (/Volumes/Data/Cloud/Project/github/partial.js-modules/dot/example/node_modules/partial.js/index.js:24:18410)
at Subscribe._end (/Volumes/Data/Cloud/Project/github/partial.js-modules/dot/example/node_modules/partial.js/index.js:24:20585)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:920:16
at process._tickCallback (node.js:415:13)

the pug module does not work

======= 2017-10-04 23:27:18: default ---> TypeError: Cannot read property 'success' of undefined (http://localhost:8000/) TypeError: Cannot read property 'success' of undefined
    at Controller.view (eval at F.install (...\node_modules\total.js\index.js:3712:48), <anonymous>:65:19)

If I comment out this line in pug.js:

self.subscribe.success();

The module works

Integration Auth0

Hello,
I found an alternative with https://auth0.com
This provider used multiples enterprises identity process.

Can you have a plan to integrate this solution in module ?

Thx

Controller or view for 404 error

Hi, below line is my controller.

F.route('/addmyinterests',addmyinterests,['post','authorize']);

I call this page via AJAX, something like the below
type:"POST",data:'value='+tobeadded_val,url:"addmyinterests", success:function(data){ $('#ui').html(data.r); }
In case the page is not unauthorized, in my AJAX, I can read the status and prompt to the users appropriately. Something like the below
(XHR.status){case 401:window.location='passport'};

For some reason, if user directly hit my URL as http://localhost/addmyinterests, then the server page response as below. Please advise how to either set template for this message or how can I redirect to login page from the server side.
404: Not Found

Thanks in advance.

Report a bug of session

Session works well in debug while always fails in test. I got code 408 each time in test mode. Finally, I found the bug is at Line 78 in session.js ,requiring a req.headers['user-agent'] which was not included in the header of test request.

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.