{"action":"created","issue":{"url":"https://api.github.com/repos/instructure/canvas-lms/issues/585","labels_url":"https://api.github.com/repos/instructure/canvas-lms/issues/585/labels{/name}","comments_url":"https://api.github.com/repos/instructure/canvas-lms/issues/585/comments","events_url":"https://api.github.com/repos/instructure/canvas-lms/issues/585/events","html_url":"https://github.com/instructure/canvas-lms/issues/585","id":57334785,"number":585,"title":"Force the user to authenticate, sending email and the field \"email\"","user":{"login":"GildedHonour","id":2032888,"avatar_url":"https://avatars.githubusercontent.com/u/2032888?v=3","gravatar_id":"","url":"https://api.github.com/users/GildedHonour","html_url":"https://github.com/GildedHonour","followers_url":"https://api.github.com/users/GildedHonour/followers","following_url":"https://api.github.com/users/GildedHonour/following{/other_user}","gists_url":"https://api.github.com/users/GildedHonour/gists{/gist_id}","starred_url":"https://api.github.com/users/GildedHonour/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GildedHonour/subscriptions","organizations_url":"https://api.github.com/users/GildedHonour/orgs","repos_url":"https://api.github.com/users/GildedHonour/repos","events_url":"https://api.github.com/users/GildedHonour/events{/privacy}","received_events_url":"https://api.github.com/users/GildedHonour/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-02-11T15:57:35Z","updated_at":"2015-02-11T18:12:56Z","closed_at":"2015-02-11T16:23:20Z","body":"A few questions:\r\n\r\n1) How to force the users authenticate to access a controller? Usually such a method is called \"authenticate_user!\" and put in \"before_filter\" at a controller level. \r\n```\r\nclass MyController < ApplicationController\r\n  before_filter :authenticate_user!\r\n  #...\r\n```\r\n\r\nBut there's \"authenticate_user!\" in canvas.\r\n\r\n2) There's no \"email\" field in the table users\r\n\r\n```\r\nCREATE TABLE users (\r\n    id bigint NOT NULL,\r\n    name character varying(255),\r\n    sortable_name character varying(255),\r\n    workflow_state character varying(255) NOT NULL,\r\n    merge_to integer,\r\n    time_zone character varying(255),\r\n    uuid character varying(255),\r\n    created_at timestamp without time zone,\r\n    updated_at timestamp without time zone,\r\n    visibility character varying(255),\r\n    avatar_image_url character varying(255),\r\n    avatar_image_source character varying(255),\r\n    avatar_image_updated_at timestamp without time zone,\r\n    phone character varying(255),\r\n    school_name character varying(255),\r\n    school_position character varying(255),\r\n    short_name character varying(255),\r\n    deleted_at timestamp without time zone,\r\n    show_user_services boolean DEFAULT true,\r\n    gender character varying(255),\r\n    page_views_count integer DEFAULT 0,\r\n    unread_inbox_items_count integer,\r\n    reminder_time_for_due_dates integer DEFAULT 172800,\r\n    reminder_time_for_grading integer DEFAULT 0,\r\n    storage_quota bigint,\r\n    visible_inbox_types character varying(255),\r\n    last_user_note timestamp without time zone,\r\n    subscribe_to_emails boolean,\r\n    features_used text,\r\n    preferences text,\r\n    avatar_state character varying(255),\r\n    locale character varying(255),\r\n    browser_locale character varying(255),\r\n    unread_conversations_count integer DEFAULT 0,\r\n    stuck_sis_fields text,\r\n    public boolean,\r\n    birthdate timestamp without time zone,\r\n    otp_secret_key_enc character varying(255),\r\n    otp_secret_key_salt character varying(255),\r\n    otp_communication_channel_id bigint,\r\n    initial_enrollment_type character varying(255),\r\n    crocodoc_id integer,\r\n    last_logged_out timestamp without time zone,\r\n    days_available character varying(255),\r\n    times_available character varying(255),\r\n    lti_context_id character varying(255),\r\n    uu_idc character varying(255),\r\n    stripe_customer_id character varying(255)\r\n);\r\n```\r\n\r\nSo where is the user's email stored? How do I get the user's (student's) email when I need to send them an email?\r\n\r\n3) And in general what's the easiest way to send an email to the user and admin? I know there's a class Mailer and a method  create_message but it seems tricky. Is there any example? \r\n\r\nI haven't found anything about those topics in the documentation."},"comment":{"url":"https://api.github.com/repos/instructure/canvas-lms/issues/comments/73932515","html_url":"https://github.com/instructure/canvas-lms/issues/585#issuecomment-73932515","issue_url":"https://api.github.com/repos/instructure/canvas-lms/issues/585","id":73932515,"user":{"login":"simonista","id":60822,"avatar_url":"https://avatars.githubusercontent.com/u/60822?v=3","gravatar_id":"","url":"https://api.github.com/users/simonista","html_url":"https://github.com/simonista","followers_url":"https://api.github.com/users/simonista/followers","following_url":"https://api.github.com/users/simonista/following{/other_user}","gists_url":"https://api.github.com/users/simonista/gists{/gist_id}","starred_url":"https://api.github.com/users/simonista/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonista/subscriptions","organizations_url":"https://api.github.com/users/simonista/orgs","repos_url":"https://api.github.com/users/simonista/repos","events_url":"https://api.github.com/users/simonista/events{/privacy}","received_events_url":"https://api.github.com/users/simonista/received_events","type":"User","site_admin":false},"created_at":"2015-02-11T18:12:56Z","updated_at":"2015-02-11T18:12:56Z","body":"If you really do need to get their account admin relationship directly, it is `user.account_users`"}}