lonnieezell / Bonfire

Jumpstart your CodeIgniter web applications with a modular, HMVC-ready, backend.
http://cibonfire.com
1.39k stars 526 forks source link

Get username directly #84

Closed thujohn closed 13 years ago

thujohn commented 13 years ago

I modified the auth library to retrieve the name of the user logged.

I can get it with : $this->auth->username()

Every update I have to do it again. Is there another way ?

ci-bonfire commented 13 years ago

Not directly, unfortunately. What I've done on some past projects is to add a $current_user var to the Admin_Controller (or Authenticated_Controller) and fill it with common values of the logged in user after login.

That would be a good addition to the lib, though. Are you able to submit a pull request with just that change in it?

thujohn commented 13 years ago

I don't see any link to submit a pull request :/

I made a pastebin : http://pastebin.com/8z9ViJur

daK76 commented 13 years ago

I have an old commit fixing this in my drawer, moslty like yours

I had it on old because what I want is, instead of feeding more kb to cookie, use an $identity userdata (email or username dinamically).

So, ideally, I want a auth->identity(). It will return according to config file preference, will setuserdata with $identity_, and also optionally returns auth->identity(email) or auth->identity(username)

Will commit the simple solution first, the other $identity is will came later, it implies refactoring and I like to carefully implement it and test it

daK76 commented 13 years ago

Neverthless... you wrote

Every update I have to do it again. Is there another way ?

Why? Git should take care of that. Are you new to git and DVCS (distributed version control)?

I don't see any link to submit a pull request :/

Humm do you have a ci-bonfire fork?

thujohn commented 13 years ago

Yes I'm new to git.

A ci-bonfire fork ? I think not.

daK76 commented 13 years ago

Ok, so if it's not a fork, there you have it, that's why you can't see it.

  1. Click on the fork button, upper right screen
  2. You'll have your first repositorie.
  3. Follow github instructions
  4. That's all, but not enough to fully understand what's going on, and what collaborating (with bonfire) means. So...

My personal advice: Go into git if you like programming, dive into it, it's a fantastic tool. You'll never regret the time you spent. For a quick crash course, and fast lean (basic) curve, search at CI- forums for GIT IMMERSION

thujohn commented 13 years ago

Thanks for the "tuto".

I plan to deepen my knowledge when I have a little more time :) I add it to my todo list ( made with Bonfire :D )

daK76 commented 13 years ago

I add it to my todo list ( made with Bonfire :D )

:) I know the feeling... finishing the ToDo and see it... Looks like it can do anything when you see that ToDo list working

I just gave a big laugh here because, being someone always fighting against my self-discipline, having hundreds of todo iPhone apps never used, I've never ever ever tought of using it to my own ticketing systems lol

doh what a dumb I am thanks for that, we're even now ;)

PS I challenge you to finish that ToDo list, by building the "done items" list right bellow. I did it and man, whata initial feeling it was PS 2 Really... don't hesitate much on GIT, dive into as soon as you program something, or just take the first lessons to get the feeling. Take 10m once in a while and start those Git Immersion lessons

thujohn commented 13 years ago

You challenge me to finish my ToDo list ??? But I have a MMORPG to finish >.<

Git Immersion lessons... Yes but I'm on Windows so lessons are a little difficults to achieve :)

daK76 commented 13 years ago

lol Don't know about your MMORPG, but the ToDo was for fun, a line 2 check if there are any soft_deletes in table, plus a view line to pick your $view_data. When you'll have the time to read documentation and play with bonfire, you'll cherry-pick my challenge, agree?

One more thing What language are you developing your MMORMAPSDFOAJE? (sorry-missed 3 times and got angry eheh)

I'm on windows. And maybe you can use GIT for your project. Don't wanna sound obsessed, but here it goes

  1. Get msysGit for windows
  2. It will install git, and a "linux" environment, meaning you'll get that DOS like session you have in GITImmersion lessons. It will also install a GUI git, which I recommend to avoid for now
  3. Prepare a folder with a copy of your MMORPG. Then open git bash icon.
  4. It will open linux shell, type cd /c/your_root_dir/your_mmorpg_project/
  5. Inside your project folder,
  6. type git init - you're saying I want BigBrother to live on this folder
  7. type git add . - Start watching everything beneath (the dot acts like .)
  8. type git commit -m "My first commit, all files added, daK is a pain in the ass" - here you instruct git to snapshot your project, recording who did it, when, and why.
  9. now minimize the linux bash, edit one of your files and save it
  10. go back to shell and type git status - You'll see BigBrother report
  11. type git add . - this time, since the file it's already added in the other commit, you're saying prepare for commit, i'm probably going to type git commit again and puts the change aside, in a staging area
  12. If yout type again git status you'll se the file is now green - meaning you agree with that change
  13. now you could do two things. Commit again with git commit -m "love you daK", or edit your file for some reason and save it again.
  14. If you did that, you would have 3 momentums of your file possible to compare on the fly: The working tree you just saved state, the staged file you added, and the way it was when you commited it first time.

Ok. Don't have any idea why I just wrote all this but here you have it :P

thujohn commented 13 years ago

Thanks for everything :)

I have time but not at the same time ^^ I can't learn by 10 minutes.

I'm using PHP/JS/SQL for my MMORPG. I wonder if I'll not use CodeIgniter to do it again :)

daK76 commented 13 years ago

I see, if you have enough experience, go with CI

Why? Well... I think you'll face some problems I had

But yes, you need time to read and learn, for everything

About GIT, it's a little diferent. You can start right away, and should (you've a big project on hands). Also because you'll only fully understand in a long time, when you'll need is power. So you better start right away since you have a big project.

If I were you, and you me, I would have the same attitude as you. I would never go without fully understand what I was going to do.

But I did same mistake, now I regret. GIT is easier to start if you start right away CLI. Reading is obligatory but practicing at the same time.

After all this, I'm sure you'll try GIT later, I was just thinking it could save your life right now (by starting to version you're MMORPG project files)

ufff :)

thujohn commented 13 years ago

I'm agree with you but the free plan doesn't accept a private project and for the moment I don't want to pay subscription :/

daK76 commented 13 years ago

there are alternatives for you MMORPG (free private), but let's not offtopic this #Issue no more

But glad you stoped by, I'm soon proposing a commit that will change auth->username, although I'm guaranteeing that it will have no impact on existing function. Since you're the only one (besides me) who hit this issue, here's the thing:

I'm extending Use.usernames to also User Name. Meaning that, those who explicity intent to, will have the user first-last name in session var instead of (exclusively) username. Plus auth->username() will return the session data var, or username from somewhere else auth->user_name() will return the session data var, or user name from somewhere else

Im' doing it because now it's the time to do it without any implication to existing users or existing performance, and because I don't wanna have another var at session (unless Lonnie thinks it's just minor bytes, having another sessionvar)

ci-bonfire commented 13 years ago

@daK - your changes were accepted in the latest pull request. Unless we find an issue down the road, we'll keep them that way for now. Thanks.